You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.8 KiB
78 lines
2.8 KiB
|
3 years ago
|
import FreeCAD as App
|
||
|
|
import FreeCADGui as Gui
|
||
|
|
import Part
|
||
|
|
|
||
|
|
|
||
|
|
from .job import LaserJob, ViewProviderLaserJob
|
||
|
|
from .pad import LaserPad, create_laserpad
|
||
|
|
|
||
|
|
class CreateCladdingJob():
|
||
|
|
def Activated(self):
|
||
|
|
# Here your write what your ScriptCmd does...
|
||
|
|
App.Console.PrintMessage('Create Lasser Cladding Job')
|
||
|
|
a=App.ActiveDocument.addObject("App::FeaturePython","LaserJob")
|
||
|
|
LaserJob(a)
|
||
|
|
ViewProviderLaserJob(a.ViewObject)
|
||
|
|
|
||
|
|
def GetResources(self):
|
||
|
|
return {'Pixmap' : 'path_to_an_icon/myicon.png', 'MenuText': 'Create Cladding Job', 'ToolTip': 'Add a Job to your Document'}
|
||
|
|
|
||
|
|
|
||
|
|
class SelectBaseReference():
|
||
|
|
def Activated(self):
|
||
|
|
# Here your write what your ScriptCmd does...
|
||
|
|
App.Console.PrintMessage('Select Base reference!')
|
||
|
|
if not Gui.Selection.hasSelection():
|
||
|
|
App.Console.PrintMessage('Select a Vertex')
|
||
|
|
return
|
||
|
|
# check length
|
||
|
|
selection = Gui.Selection.getSelectionEx()
|
||
|
|
# find first vertex
|
||
|
|
for s in selection:
|
||
|
|
if s.HasSubObjects:
|
||
|
|
for obj in s.SubObjects:
|
||
|
|
if isinstance(obj, Part.Vertex):
|
||
|
|
vertex = obj.copy()
|
||
|
|
laserjob_entry = App.ActiveDocument.getObject('LaserJob')
|
||
|
|
if laserjob_entry is None:
|
||
|
|
App.Console.PrintMessage('Create a LaserJob first')
|
||
|
|
return
|
||
|
|
laserjob_entry.base_reference = App.Vector((vertex.X, vertex.Y, vertex.Z))
|
||
|
|
App.ActiveDocument.recompute()
|
||
|
|
|
||
|
|
|
||
|
|
def GetResources(self):
|
||
|
|
return {'Pixmap' : 'path_to_an_icon/myicon.png', 'MenuText': 'Select Base reference', 'ToolTip': 'Add a Job to your Document'}
|
||
|
|
|
||
|
|
|
||
|
|
class CreatePad():
|
||
|
|
def Activated(self):
|
||
|
|
# Here your write what your ScriptCmd does...
|
||
|
|
App.Console.PrintMessage('Select some Face as reference')
|
||
|
|
if not Gui.Selection.hasSelection():
|
||
|
|
App.Console.PrintMessage('Select a Face')
|
||
|
|
return
|
||
|
|
# check length
|
||
|
|
ref_face = (Gui.Selection.getSelection()[0],
|
||
|
|
Gui.Selection.getSelectionEx()[0].SubElementNames[0])
|
||
|
|
#selection = Gui.Selection.getSelectionEx()
|
||
|
|
# find first vertex
|
||
|
|
#for s in selection:
|
||
|
|
# if s.HasSubObjects:
|
||
|
|
# for obj in s.SubObjects:
|
||
|
|
# if isinstance(obj, Part.Face):
|
||
|
|
# face = obj.copy()
|
||
|
|
create_laserpad(ref_face)
|
||
|
|
App.ActiveDocument.recompute()
|
||
|
|
|
||
|
|
|
||
|
|
def GetResources(self):
|
||
|
|
return {'Pixmap' : 'path_to_an_icon/myicon.png', 'MenuText': 'Select Base reference', 'ToolTip': 'Add a Job to your Document'}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
Gui.addCommand('CreateCladdingJob', CreateCladdingJob())
|
||
|
|
Gui.addCommand('SelectBaseReference', SelectBaseReference())
|
||
|
|
Gui.addCommand('CreatePad', CreatePad())
|