-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScriptFreeCAD.py
109 lines (77 loc) · 2.67 KB
/
ScriptFreeCAD.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# -*- coding: utf-8 -*-
import FreeCAD
import Part
import Import
import Mesh
App.ActiveDocument=None
doc = FreeCAD.newDocument("Noname")
App.setActiveDocument("Noname")
App.ActiveDocument = App.getDocument("Noname")
TibiaStp = Part.read("CWD\Tibia_NAME.stp")
CementStp = Part.read("PATH2CEMENT")
CutProthStp = Part.read("PATH2CUT")
ProthStp = Part.read("PATH2IMPLANT")
CondylesMsh = Mesh.read("CWD\Condyles4Mimics.stl")
doc.recompute()
Tibia = doc.addObject("Part::Feature","Tibia")
Tibia.Shape = TibiaStp
Tibia2 = doc.addObject("Part::Feature","Tibia2")
Tibia2.Shape = TibiaStp
Cement = doc.addObject("Part::Feature","Cement")
Cement.Shape = CementStp
CutProth = doc.addObject("Part::Feature","CutProth")
CutProth.Shape = CutProthStp
CutProth2 = doc.addObject("Part::Feature","CutProth2")
CutProth2.Shape = CutProthStp
Proth = doc.addObject("Part::Feature","Proth")
Proth.Shape = ProthStp
Condyles = doc.addObject("Mesh::Feature","Condyles")
Condyles.Mesh = CondylesMsh
matTsfrm=FreeCAD.Matrix()
matTsfrm.scale(ML_WIDTH,AP_WIDTH,1.0)
CdlMesh=doc.Condyles.Mesh.copy()
CdlMesh.transform(matTsfrm)
doc.recompute()
NEW_PLACEMENT_MATRIX
NEW_PLACEMENT_ANAT_MATRIX
doc.recompute()
CutProth.Placement = newplace
CutProth2.Placement = newplace
Proth.Placement = newplace
Cement.Placement = newplace
CdlMesh.Placement = FreeCAD.Placement(newplaceAnat)
doc.recompute()
Mesh.show(CdlMesh)
doc.recompute()
App.activeDocument().addObject("Part::Cut","TibiaCutted")
App.activeDocument().TibiaCutted.Base = Tibia
App.activeDocument().TibiaCutted.Tool = CutProth
App.activeDocument().addObject("Part::MultiCommon","TibialCut")
App.activeDocument().TibialCut.Shapes = [Tibia2, CutProth2,]
doc.recompute()
__objs__=[]
__objs__.append(FreeCAD.getDocument("Noname").getObject("TibiaCutted"))
Import.export(__objs__,u"CWD\Output\NAME\Tibia_NAME_cutted_aALPHA.step")
del __objs__
__objs__=[]
__objs__.append(FreeCAD.getDocument("Noname").getObject("TibialCut"))
Import.export(__objs__,u"CWD\Output\NAME\Tibia_NAME_cut_aALPHA.step")
del __objs__
__objs__=[]
__objs__.append(FreeCAD.getDocument("Noname").getObject("Proth"))
Import.export(__objs__,u"CWD\Output\NAME\Implant_SIZE_WLS_NAME_aALPHA.step")
del __objs__
__objs__=[]
__objs__.append(FreeCAD.getDocument("Noname").getObject("Cement"))
Import.export(__objs__,u"CWD\Output\NAME\C_SIZE_WLS_NAME_aALPHA.step")
del __objs__
__objs__=[]
__objs__.append(FreeCAD.getDocument("Noname").getObject("CutProth"))
Import.export(__objs__,u"CWD\Output\NAME\CutProth_SIZE_WLS_NAME_aALPHA.step")
del __objs__
__objs__=[]
__objs__.append(FreeCAD.getDocument("Noname").getObject("Mesh"))
import Mesh
Mesh.export(__objs__,u"CWD\Output\NAME\Condyle_NAME_aALPHA.stl")
del __objs__
quit()