-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuto_Draw.py
More file actions
126 lines (92 loc) · 4.08 KB
/
Auto_Draw.py
File metadata and controls
126 lines (92 loc) · 4.08 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
############################################################################################
# Script to auto Generate the Drawings.
###########################################################################################
import FreeCAD
import TechDraw
#-----------------------------------------------------------------------------------------
#The selected part in GUI is given a name
Target = Gui.Selection.getSelectionEx()[0]
#-----------------------------------------------------------------------------------------
#function to add new document(page)
def New_page():
App.activeDocument().addObject('TechDraw::DrawPage','Drawing')
App.activeDocument().addObject('TechDraw::DrawSVGTemplate','Template')
App.activeDocument().Template.Template = '/usr/share/freecad/Mod/TechDraw/Templates/A2_Landscape_ISO7200TD.svg'
App.activeDocument().Drawing.Template = App.activeDocument().Template
#EoF
#-----------------------------------------------------------------------------------------
#Assigning value of boundary of box of Target(Object)
Length = Target.Object.Shape.BoundBox.XMax
Height = Target.Object.Shape.BoundBox.ZMax
Width = Target.Object.Shape.BoundBox.YMax
#Assigning scaling values
Sc0 = (550)/(Length)
Sc1 = (400)/(Height)
Sc2 = (400)/(Width)
Scale0 = Sc0
if Scale0 > Sc1 :
Scale0 = Sc1
if Scale0 > Sc2 :
Scale0 = Sc2
#-----------------------------------------------------------------------------------------
#Assigning Position coordinates
Scale = Scale0/4
TopX = 40+Scale*Length
TopY = 30+Scale*Width
FrontX = 40+Scale*Length
FrontY = 30+3*Scale*Width
RightX = 40+4*Scale*Length
RightY = 30+3*Scale*Width
#-----------------------------------------------------------------------------------------
#function to add the top views of object.
def Top_view():
App.activeDocument().addObject('TechDraw::DrawViewPart','topView')
App.activeDocument().topView.Source = Target.Object
App.activeDocument().Drawing.addView(App.activeDocument().topView)
App.activeDocument().topView.Direction = (0,0,1)
App.activeDocument().topView.X = TopX
App.activeDocument().topView.Y = TopY
App.activeDocument().topView.Scale = Scale
#EoF
#----------------------------------------------------------------------------------------
#Create FrontView
def Front_view():
App.activeDocument().addObject('TechDraw::DrawViewPart','FrontView')
App.activeDocument().FrontView.Source = Target.Object
App.activeDocument().Drawing.addView(App.activeDocument().FrontView)
App.activeDocument().FrontView.Direction = (0,-1,0)
App.activeDocument().FrontView.X = FrontX
App.activeDocument().FrontView.Y = FrontY
App.activeDocument().FrontView.Scale = Scale
#EoF
##----------------------------------------------------------------------------------------
#Create RightView
def Side_view():
App.activeDocument().addObject('TechDraw::DrawViewPart','SideView')
App.activeDocument().SideView.Source = Target.Object
App.activeDocument().Drawing.addView(App.activeDocument().SideView)
App.activeDocument().SideView.Direction = (1,0,0)
App.activeDocument().SideView.X = RightX
App.activeDocument().SideView.Y = RightY
App.activeDocument().SideView.Scale = Scale
#EoF
#---------------------------------------------------------------------------------------
#Create IsotView
def Iso_view():
App.activeDocument().addObject('TechDraw::DrawViewPart','IsoView')
App.activeDocument().IsoView.Source = Target.Object
App.activeDocument().Drawing.addView(App.activeDocument().IsoView)
App.activeDocument().IsoView.Direction = (1,1,1)
App.activeDocument().IsoView.X = RightX
App.activeDocument().IsoView.Y = TopY
App.activeDocument().IsoView.Scale = Scale
#----------------------------------------------------------------------------------------
#Calling of functions
New_page()
Top_view()
Front_view()
Side_view()
Iso_view()
############################################################################################
#Script ends
############################################################################################