-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport_dxf.FCMacro
47 lines (34 loc) · 1.41 KB
/
export_dxf.FCMacro
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
# -*- coding: utf-8 -*-
# Macro Begin: /home/pampa/.FreeCAD/Macro/export_draft.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
import FreeCAD
import Draft
#import gui_shape2dview
import importDXF
import FreeCADGui
obj = []
for selection in FreeCADGui.Selection.getSelectionEx():
obj = selection.Object
if hasattr(obj, 'Label'):
obj_name = obj.Label
else:
FreeCAD.Console.PrintMessage("The given object must have a name attribute\n")
quit()
FreeCAD.Console.PrintMessage("Object Name: " + obj_name + "\n")
orientation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()
direction = Gui.ActiveDocument.ActiveView.getViewDirection()
FreeCAD.Console.PrintMessage(orientation)
FreeCAD.Console.PrintMessage("\n")
FreeCAD.Console.PrintMessage(direction)
FreeCAD.Console.PrintMessage("\n")
if Draft.makeShape2DView(obj, FreeCAD.Vector(direction)):
FreeCAD.Console.PrintMessage("created shape 2d!\n")
for selection in FreeCADGui.Selection.getSelectionEx():
shape = selection.Object
shape_name = shape.Label
FreeCAD.Console.PrintMessage("Shape Name: " + shape_name + "\n")
shape.Label = obj_name + "_shape"
FreeCAD.ActiveDocument.recompute()
#filename = "/wrk/now/bibliohack/Cenital/_laser_cut/1250x900_2/frame_and_camera/"+ shape.Label + ".dxf"
__objs__=[]
__objs__.append(shape)
importDXF.export(__objs__, u"/wrk/now/bibliohack/Cenital/_laser_cut/1250x900_2/frame_and_camera/" + shape.Label + u".dxf")