3D CAD

매크로로 작성한 3D CAD 모델 조립 과정 test

edblab 2023. 5. 2. 10:00
728x90

FreeCAD로 작성된 조립품의 조립 과정을 작업자에게 그래픽하게 보여주는 기능을 시험 중이다. FreeCAD의 매크로 기능을 이용하면 비교적 쉽게 조립 과정을 보여줄 수 있을 것으로 예측된다. 현재는 수작업으로 작성한 매크로를 이용해서 과정을 생성해 보았다.

#hide column, shaft
Gui.Selection.addSelection('asmD','Part','Part__Feature001.')
Gui.Selection.addSelection('asmD','Part','Part__Feature002.')
Gui.runCommand('Std_ToggleVisibility',0)
Gui.Selection.clearSelection()
#1 move base to start p
App.getDocument("asmD").Part__Feature.Placement=App.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(1,0,0),0),App.Vector(0,0,0))
# move base to base p
App.getDocument("asmD").Part__Feature.Placement=App.Placement(App.Vector(30,30,0),App.Rotation(App.Vector(1,0,0),0),App.Vector(0,0,0))
#show column
Gui.Selection.addSelection('asmD','Part','Part__Feature001.')
Gui.runCommand('Std_ToggleVisibility',0)
Gui.Selection.clearSelection()
#2 move column to start p
App.getDocument("asmD").Part__Feature001.Placement=App.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(1,0,0),0),App.Vector(0,0,0))
# move column to base p
App.getDocument("asmD").Part__Feature001.Placement=App.Placement(App.Vector(30,30,2),App.Rotation(App.Vector(1,0,0),0),App.Vector(0,0,0))
#show shaft
Gui.Selection.addSelection('asmD','Part','Part__Feature002.')
Gui.runCommand('Std_ToggleVisibility',0)
Gui.Selection.clearSelection()

#3 move shaft to start p
App.getDocument("asmD").Part__Feature002.Placement=App.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(1,0,0),0),App.Vector(0,0,0))
#3 rotate shaft at start p
App.getDocument("asmD").Part__Feature002.Placement=App.Placement(App.Vector(0,0,7.5),App.Rotation(App.Vector(1,0,0),90),App.Vector(0,0,0))
# move shaft to base p
App.getDocument("asmD").Part__Feature002.Placement=App.Placement(App.Vector(30,38,27),App.Rotation(App.Vector(1,0,0),90),App.Vector(0,0,0))

 

다음은 수작업으로 매크로를 실행한 결과이다.

2023 EDBLab