本文整理汇总了Python中Drawing.projectToDXF方法的典型用法代码示例。如果您正苦于以下问题:Python Drawing.projectToDXF方法的具体用法?Python Drawing.projectToDXF怎么用?Python Drawing.projectToDXF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drawing
的用法示例。
在下文中一共展示了Drawing.projectToDXF方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_xyz_to_dxf
# 需要导入模块: import Drawing [as 别名]
# 或者: from Drawing import projectToDXF [as 别名]
def export_xyz_to_dxf(ai_solid, ai_size_x, ai_size_y, ai_size_z, ai_xy_slice_list, ai_xz_slice_list, ai_yz_slice_list, ai_output_file):
""" Cut a FreeCAD Part Object in many slices in the three directions X, Y and Z and put all those slices in a DXF file
"""
# calculate the space between two drawings
l_space = max(ai_size_x/5.0, ai_size_y/5.0, ai_size_z/5.0)
#
vec_z_unit = Base.Vector(0,0,1)
#
l_slice_list = []
l_pos_y = 0
for lo in ['xy','xz','yz']:
#l_solid = ai_solid
l_solid = ai_solid.copy()
l_depth_list = []
l_shift_x = 0
l_gauge_max = 0
if(lo=='xy'):
l_solid.rotate(Base.Vector(ai_size_x/2.0, ai_size_y/2.0, ai_size_z/2.0), Base.Vector(0,0,1), 0)
l_solid.translate(Base.Vector(0,0,0)) # place the module corner at origin (0,0,0)
l_solid.translate(Base.Vector(0,2*ai_size_z+7*l_space,0))
l_pos_y = 2*ai_size_z+6*l_space
l_depth_list = ai_xy_slice_list
l_shift_x = ai_size_x
l_gauge_max = ai_size_z
elif(lo=='xz'):
l_solid.rotate(Base.Vector(ai_size_x/2.0, ai_size_y/2.0, ai_size_z/2.0), Base.Vector(1,0,0), -90)
l_solid.translate(Base.Vector((ai_size_x-ai_size_x)/2.0, (ai_size_z-ai_size_y)/2.0, (ai_size_y-ai_size_z)/2.0)) # place the module corner at origin (0,0,0)
l_solid.translate(Base.Vector(0,1*ai_size_z+4*l_space,0))
l_pos_y = 1*ai_size_z+3*l_space
l_depth_list = ai_xz_slice_list
l_shift_x = ai_size_x
l_gauge_max = ai_size_y
elif(lo=='yz'):
l_solid.rotate(Base.Vector(ai_size_x/2.0, ai_size_y/2.0, ai_size_z/2.0), Base.Vector(0,0,1), -90)
l_solid.rotate(Base.Vector(ai_size_x/2.0, ai_size_y/2.0, ai_size_z/2.0), Base.Vector(1,0,0), -90)
l_solid.translate(Base.Vector((ai_size_y-ai_size_x)/2.0, (ai_size_z-ai_size_y)/2.0, (ai_size_x-ai_size_z)/2.0)) # place the module corner at origin (0,0,0)
l_solid.translate(Base.Vector(0,l_space,0))
l_pos_y = 0*ai_size_z+0*l_space
l_depth_list = ai_yz_slice_list
l_shift_x = ai_size_y
l_gauge_max = ai_size_x
l_pos_x = 0
for l_depth in l_depth_list:
#print("dbg163: l_shift_x l_space l_gauge_max l_depth l_pos_x l_pos_y", l_shift_x, l_space, l_gauge_max, l_depth, l_pos_x, l_pos_y)
l_slice_list.extend(draw_gauge(l_shift_x, l_space/2.0, l_gauge_max, l_depth, l_pos_x, l_pos_y))
l_pos_x += l_shift_x+2*l_space
ll_depth = l_depth
if(lo=='xz'):
ll_depth = ai_size_y-l_depth
#print("dbg168: ll_depth:", ll_depth)
l_slice_list.extend(l_solid.slice(vec_z_unit, ll_depth))
l_solid.translate(Base.Vector(l_shift_x+2*l_space,0,0))
l_slice = Part.makeCompound(l_slice_list)
r_dxf = Drawing.projectToDXF(l_slice, vec_z_unit)
#r_dxf = Drawing.projectToDXF(ai_solid, ai_vector)
fh_output = open(ai_output_file, 'w')
fh_output.write(r_dxf)
fh_output.close()
return(1)
示例2: getDXF
# 需要导入模块: import Drawing [as 别名]
# 或者: from Drawing import projectToDXF [as 别名]
def getDXF(self,obj):
"returns a DXF representation of the view"
if obj.RenderingMode == "Solid":
print "Unable to get DXF from Solid mode: ",obj.Label
return ""
result = []
import Drawing
if not hasattr(self,"baseshape"):
self.onChanged(obj,"Source")
if hasattr(self,"baseshape"):
if self.baseshape:
result.append(Drawing.projectToDXF(self.baseshape,self.direction))
if hasattr(self,"sectionshape"):
if self.sectionshape:
result.append(Drawing.projectToDXF(self.sectionshape,self.direction))
if hasattr(self,"hiddenshape"):
if self.hiddenshape:
result.append(Drawing.projectToDXF(self.hiddenshape,self.direction))
return result
示例3: getDXF
# 需要导入模块: import Drawing [as 别名]
# 或者: from Drawing import projectToDXF [as 别名]
def getDXF(self):
"returns a flat shape representation of the view"
if hasattr(self,"baseshape"):
import Drawing
[V0,V1,H0,H1] = Drawing.project(self.baseshape,self.direction)
DxfOutput = Drawing.projectToDXF(self.baseshape,self.direction)
return DxfOutput
else:
FreeCAD.Console.PrintMessage(translate("Arch","No shape has been computed yet, select wireframe rendering and render again"))
return None
示例4: export_to_dxf
# 需要导入模块: import Drawing [as 别名]
# 或者: from Drawing import projectToDXF [as 别名]
def export_to_dxf(ai_solid, ai_vector, ai_depth, ai_output_file):
""" create a DXF of a slice of FreeCAD Part Object
"""
l_slice = Part.makeCompound(ai_solid.slice(ai_vector, ai_depth)) # slice the plank in the ai_vector plan at a the height ai_depth
r_dxf = Drawing.projectToDXF(l_slice, ai_vector)
#r_dxf = Drawing.projectToDXF(ai_solid, ai_vector) # works also :)
fh_output = open(ai_output_file, 'w')
fh_output.write(r_dxf)
fh_output.close()
return(1)
示例5: getDXF
# 需要导入模块: import Drawing [as 别名]
# 或者: from Drawing import projectToDXF [as 别名]
def getDXF(obj):
"returns a DXF representation from a TechDraw/Drawing view"
allOn = True
if hasattr(obj,"AllOn"):
allOn = obj.AllOn
elif hasattr(obj,"AlwaysOn"):
allOn = obj.AlwaysOn
showHidden = False
if hasattr(obj,"showCut"):
showHidden = obj.showCut
elif hasattr(obj,"showHidden"):
showHidden = obj.showHidden
result = []
import Drawing,Part
if not obj.Source:
return result
section = obj.Source
if not section.Objects:
return result
p = FreeCAD.Placement(section.Placement)
direction = p.Rotation.multVec(FreeCAD.Vector(0,0,1))
objs = Draft.getGroupContents(section.Objects,walls=True,addgroups=True)
if not allOn:
objs = Draft.removeHidden(objs)
# separate spaces and Draft objects
spaces = []
nonspaces = []
drafts = []
objs = [o for o in objs if ((not(Draft.getType(o) in ["Space","Dimension","Annotation"])) and (not (o.isDerivedFrom("Part::Part2DObject"))))]
shapes,hshapes,sshapes,cutface,cutvolume,invcutvolume = getCutShapes(objs,section,showHidden)
if shapes:
result.append(Drawing.projectToDXF(Part.makeCompound(shapes),direction))
if sshapes:
result.append(Drawing.projectToDXF(Part.makeCompound(sshapes),direction))
if hshapes:
result.append(Drawing.projectToDXF(Part.makeCompound(hshapes),direction))
return result
示例6: open
# 需要导入模块: import Drawing [as 别名]
# 或者: from Drawing import projectToDXF [as 别名]
sel = Gui.Selection.getSelectionEx()
face = sel[0].SubObjects[0]
import Drawing
open('/tmp/out.dxf', 'w').write(Drawing.projectToDXF(face, App.Vector(0, 0, 1)))