1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
20 "name": "Import Autocad DXF Format (.dxf)",
21 "author": "Thomas Larsson, Remigiusz Fiedler",
23 "blender": (2, 63, 0),
24 "location": "File > Import > Autocad (.dxf)",
25 "description": "Import files in the Autocad DXF format (.dxf)",
26 "warning": "Under construction! Visit Wiki for details.",
27 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
28 "Scripts/Import-Export/DXF_Importer",
29 "tracker_url": "https://developer.blender.org/T23480",
30 "support": "OFFICIAL",
31 "category": "Import-Export",
35 Release note by migius (DXF support maintainer) 2011.01.02:
36 Script supports only a small part of DXF specification:
37 - imports LINE, ARC, CIRCLE, ELLIPSE, SOLID, TRACE, POLYLINE, LWPOLYLINE
39 - supports 3d-rotation of entities (210 group)
40 - supports THICKNESS for SOLID, TRACE, LINE, ARC, CIRCLE, ELLIPSE
41 - ignores WIDTH, THICKNESS, BULGE in POLYLINE/LWPOLYLINE
42 - ignores face-data in POLYFACE / POLYMESH
43 - ignores TEXT 2d-rotation
44 - ignores hierarchies (BLOCK, INSERT, GROUP)
46 - ignores COLOR, LINEWIDTH, LINESTYLE
48 This script is a temporary solution.
49 No functionality improvements are planed for this version.
50 The advanced importer from 2.49 will replace it in the future.
53 Place this file to Blender addons directory
54 (on Windows it is %Blender_directory%\2.53\scripts\addons\)
55 The script must be activated in "Addons" tab (user preferences).
56 Access it from File > Import menu.
59 ver 0.1.6 - 2012.01.03 by migius and trumanblending for r.42615
60 - modified for recent changes to matrix indexing
61 ver 0.1.5 - 2011.02.05 by migius for r.34661
62 - changed support level to OFFICIAL
63 - fixed missing last point at building Mesh-ARCs (by pildanovak)
64 - fixed for changes in API and mathutils by campbell
65 ver 0.1.4 - 2011.01.13 by migius
66 - modified for latest API in rev.34300 (by Filiciss Muhgue)
67 ver 0.1.3 - 2011.01.02 by migius
68 - added draw curves as sequence for "Draw_as_Curve"
69 - added toggle "Draw as one" as user preset in UI
70 - added draw POINT as mesh-vertex
71 - added draw_THICKNESS for LINE, ARC, CIRCLE, ELLIPSE, LWPOLYLINE and POLYLINE
72 - added draw_THICKNESS for SOLID, TRACE
73 ver 0.1.2 - 2010.12.27 by migius
74 - added draw() for TRACE
75 - fixed wrong vertex order in SOLID
76 - added CIRCLE resolution as user preset in UI
77 - added closing segment for circular LWPOLYLINE and POLYLINE
78 - fixed registering for 2.55beta
79 ver 0.1.1 - 2010.09.07 by migius
80 - fixed dxf-file names recognition limited to ".dxf"
81 - fixed registering for 2.53beta
82 ver 0.1 - 2010.06.10 by Thomas Larsson
85 __version__
= '.'.join([str(s
) for s
in bl_info
['version']])
90 from math
import sin
, cos
, radians
92 from mathutils
import Vector
, Matrix
106 toggle
= T_Merge | T_NewScene | T_DrawOne | T_ThicON
121 print("Section", self
.type)
122 for datum
in self
.data
:
138 print("Table %s %s %s %s %s %d" % (self
.type, self
.name
, self
.handle
, self
.owner
, self
.subclass
, self
.nEntries
))
144 def __init__(self
, typ
, drawtype
):
146 self
.drawtype
= drawtype
153 self
.linetype_name
= ''
154 self
.linetype_scale
= 1.0
156 #self.normal = Vector((0,0,1))
159 print("Entity %s %s %s %s %s %s %x" %
160 (self
.type, self
.handle
, self
.owner
, self
.subclass
, self
.layer
, self
.color
, self
.invisible
))
162 def build(self
, vn
=0):
165 raise NameError("Warning: can not build - unsupported entity type: %s" % self
.type)
166 return(([], [], [], vn
))
171 raise NameError("Warning: can not draw - unsupported entity type: %s" % self
.type)
175 DxfCommonAttributes
= {
179 48 : 'linetype_scale',
189 # class C3dFace(CEntity):
190 # 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
191 # 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
192 # 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
193 # 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
197 class C3dFace(CEntity
):
199 CEntity
.__init
__(self
, '3DFACE', 'Mesh')
200 self
.point0
= Vector()
201 self
.point1
= Vector()
202 self
.point2
= Vector()
203 self
.point3
= Vector()
206 CEntity
.display(self
)
212 def build(self
, vn
=0):
213 verts
= [self
.point0
, self
.point1
, self
.point2
]
214 if self
.point3
== Vector((0,0,0)) or self
.point2
== self
.point3
:
215 faces
= [(vn
+0, vn
+1, vn
+2)]
218 verts
.append( self
.point3
)
219 faces
= [(vn
+0, vn
+1, vn
+2, vn
+3)]
221 return((verts
, [], faces
, vn
))
224 # class C3dSolid(CEntity):
225 # 1 : 'data', 3 : 'more', 70 : 'version',
228 class C3dSolid(CEntity
):
230 CEntity
.__init
__(self
, '3DSOLID', 'Mesh')
236 # class CAcadProxyEntity(CEntity):
238 # 90 : 'id', 91 : 'class', 92 : 'graphics_size', 93 : 'entity_size', 95: 'format',
239 # 310 : 'data', 330 : 'id1', 340 : 'id2', 350 : 'id3', 360 : 'id4',
242 class CAcadProxyEntity(CEntity
):
244 CEntity
.__init
__(self
, 'ACAD_PROXY_ENTITY', None)
248 # class CArc(CEntity):
249 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
251 # 50 : 'start_angle', 51 : 'end_angle'
256 CEntity
.__init
__(self
, 'ARC', 'Mesh')
257 self
.center
= Vector()
259 self
.start_angle
= 0.0
262 self
.normal
= Vector((0,0,1))
265 CEntity
.display(self
)
267 print("%.4f %.4f %.4f " % (self
.radius
, self
.start_angle
, self
.end_angle
))
269 def build(self
, vn
=0):
270 start
, end
= self
.start_angle
, self
.end_angle
271 if end
> 360: end
= end
% 360.0
272 if end
< start
: end
+=360.0
273 # angle = end - start # UNUSED
275 deg2rad
= math
.pi
/180.0
280 w
= dphi
/theCircleRes
285 edges
, faces
= [], []
286 for n
in range(theCircleRes
+ 1):
287 s
= math
.sin(n
*w
+ phi0
)
288 c
= math
.cos(n
*w
+ phi0
)
289 v
= center
+ Vector((r
*c
, r
*s
, 0.0))
292 thic
= self
.thickness
293 t_vector
= Vector((0, 0, thic
))
294 if thic
!= 0 and (toggle
& T_ThicON
):
295 thic_points
= [v
+ t_vector
for v
in points
]
297 thic_points
.extend(points
)
300 points
.extend(thic_points
)
301 faces
= [(v0
+nr
+0,v0
+nr
+1,v0
+pn
+nr
+1,v0
+pn
+nr
+0) for nr
in range(pn
)]
303 self
.drawtype
= 'Mesh'
306 edges
= [(v0
+nr
+0,v0
+nr
+1) for nr
in range(pn
)]
310 if self
.normal
!=Vector((0,0,1)):
311 ma
= getOCS(self
.normal
)
314 points
= [ma
* v
for v
in points
]
315 #print ('arc vn=', vn)
316 #print ('faces=', len(faces))
317 return ((points
, edges
, faces
, vn
))
320 # class CArcAlignedText(CEntity):
321 # 1 : 'text', 2 : 'font', 3 : 'bigfont', 7 : 'style',
322 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
323 # 40 : 'radius', 41 : 'width', 42 : 'height', 43 : 'spacing',
324 # 44 : 'offset', 45 : 'right_offset', 46 : 'left_offset',
325 # 50 : 'start_angle', 51 : 'end_angle',
326 # 70 : 'order', 71 : 'direction', 72 : 'alignment', 73 : 'side',
327 # 74 : 'bold', 75 : 'italic', 76 : 'underline',
328 # 77 : 'character_set', 78 : 'pitch', 79 'fonttype',
330 # 280 : 'wizard', 330 : 'id'
333 class CArcAlignedText(CEntity
):
335 CEntity
.__init
__(self
, 'ARCALIGNEDTEXT', 'Mesh')
338 self
.center
= Vector()
344 self
.right_offset
= 0.0
345 self
.left_offset
= 0.0
346 self
.start_angle
= 0.0
355 self
.character_set
= 0
361 self
.normal
= Vector((0,0,1))
365 # class CAttdef(CEntity):
366 # 1 : 'text', 2 : 'tag', 3 : 'prompt', 7 : 'style',
367 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
368 # 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
369 # 40 : 'height', 41 : 'x_scale',
370 # 50 : 'rotation_angle', 51 : 'oblique_angle',
371 # 70 : 'flags', 71 : 'text_generation_flags',
372 # 72 : 'horizontal_justification', 74 : 'vertical_justification',
375 class CAttdef(CEntity
):
377 CEntity
.__init
__(self
, 'ATTDEF', None)
382 self
.insertion_point
= Vector()
383 self
.alignment_point
= Vector()
386 self
.rotation_angle
= 0.0
387 self
.oblique_angle
= 0.0
389 self
.text_generation_flags
= 0
390 self
.horizontal_justification
= 0.0
391 self
.vertical_justification
= 0.0
392 self
.normal
= Vector((0,0,1))
395 drawText(self
.text
, self
.insertion_point
, self
.height
, self
.x_scale
, self
.rotation_angle
, self
.oblique_angle
, self
.normal
)
399 # class CAttrib(CEntity):
400 # 1 : 'text', 2 : 'tag', 3 : 'prompt', 7 : 'style',
401 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
402 # 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
403 # 40 : 'height', 41 : 'x_scale',
404 # 50 : 'rotation_angle', 51 : 'oblique_angle',
405 # 70 : 'flags', 73 : 'length',
406 # 71 : 'text_generation_flags', 72 : 'horizontal_justification', 74 : 'vertical_justification',
409 class CAttrib(CEntity
):
411 CEntity
.__init
__(self
, 'ATTRIB', None)
417 self
.insertion_point
= Vector()
418 self
.alignment_point
= Vector()
421 self
.rotation_angle
= 0.0
422 self
.oblique_angle
= 0.0
425 self
.text_generation_flags
= 0
426 self
.horizontal_justification
= 0.0
427 self
.vertical_justification
= 0.0
428 self
.normal
= Vector((0,0,1))
431 drawText(self
.text
, self
.insertion_point
, self
.height
, self
.x_scale
, self
.rotation_angle
, self
.oblique_angle
, self
.normal
)
436 # class CBlock(CEntity):
437 # 1 : 'xref', 2 : 'name', 3 : 'also_name',
438 # 10 : 'base_point.x', 20 : 'base_point.y', 30 : 'base_point.z',
439 # 40 : 'size', 41 : 'x_scale',
440 # 50 : 'rotation_angle', 51 : 'oblique_angle',
444 class CBlock(CEntity
):
446 CEntity
.__init
__(self
, 'BLOCK', None)
450 self
.base_point
= Vector()
453 self
.rotation_angle
= 0.0
454 self
.oblique_angle
= 0.0
456 self
.normal
= Vector((0,0,1))
459 CEntity
.display(self
)
460 print("%s %s %s " % (self
.xref
, self
.name
, self
.also_name
))
461 print(self
.base_point
)
468 # class CCircle(CEntity):
469 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
473 class CCircle(CEntity
):
475 CEntity
.__init
__(self
, 'CIRCLE', 'Mesh')
476 self
.center
= Vector()
479 self
.normal
= Vector((0,0,1))
482 CEntity
.display(self
)
484 print("%.4f" % self
.radius
)
486 def build(self
, vn
=0):
487 w
= 2*math
.pi
/theCircleRes
491 edges
, faces
= [], []
493 for n
in range(theCircleRes
):
496 v
= center
+ Vector((r
*c
, r
*s
, 0))
500 thic
= self
.thickness
501 t_vector
= Vector((0, 0, thic
))
502 if thic
!= 0 and (toggle
& T_ThicON
):
503 thic_points
= [v
+ t_vector
for v
in points
]
505 thic_points
.extend(points
)
508 points
.extend(thic_points
)
509 faces
= [(v0
+nr
,v0
+nr
+1,pn
+v0
+nr
+1,pn
+v0
+nr
) for nr
in range(pn
)]
511 faces
[-1] = (v0
+nr
,v0
,pn
+v0
,pn
+v0
+nr
)
512 self
.drawtype
= 'Mesh'
515 edges
= [(v0
+nr
,v0
+nr
+1) for nr
in range(pn
)]
517 edges
[-1] = (v0
+nr
,v0
)
519 if self
.normal
!=Vector((0,0,1)):
520 ma
= getOCS(self
.normal
)
523 points
= [ma
* v
for v
in points
]
524 #print ('cir vn=', vn)
525 #print ('faces=',len(faces))
526 return( (points
, edges
, faces
, vn
) )
529 # class CDimension(CEntity):
530 # 1 : 'text', 2 : 'name', 3 : 'style',
531 # 10 : 'def_point.x', 20 : 'def_point.y', 30 : 'def_point.z',
532 # 11 : 'mid_point.x', 21 : 'mid_point.y', 31 : 'mid_point.z',
533 # 12 : 'vector.x', 22 : 'vector.y', 32 : 'vector.z',
534 # 13 : 'def_point2.x', 23 : 'def_point2.y', 33 : 'def_point2.z',
535 # 14 : 'vector2.x', 24 : 'vector2.y', 34 : 'vector2.z',
536 # 15 : 'vector3.x', 25 : 'vector3.y', 35 : 'vector3.z',
537 # 16 : 'vector4.x', 26 : 'vector4.y', 36 : 'vector4.z',
541 class CDimension(CEntity
):
543 CEntity
.__init
__(self
, 'DIMENSION', None)
547 self
.def_point
= Vector()
548 self
.mid_point
= Vector()
549 self
.vector
= Vector()
550 self
.def_point2
= Vector()
551 self
.vector2
= Vector()
552 self
.vector3
= Vector()
553 self
.vector4
= Vector()
555 self
.normal
= Vector((0,0,1))
561 # class CEllipse(CEntity):
562 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
563 # 11 : 'end_point.x', 21 : 'end_point.y', 31 : 'end_point.z',
564 # 40 : 'ratio', 41 : 'start', 42 : 'end',
567 class CEllipse(CEntity
):
569 CEntity
.__init
__(self
, 'ELLIPSE', 'Mesh')
570 self
.center
= Vector()
571 self
.end_point
= Vector()
576 self
.normal
= Vector((0,0,1))
579 CEntity
.display(self
)
581 print("%.4f" % self
.ratio
)
583 def build(self
, vn
=0):
584 dphi
= (self
.end
- self
.start
)
586 w
= dphi
/theCircleRes
587 r
= self
.end_point
.length
589 a
= self
.end_point
.x
/r
590 b
= self
.end_point
.y
/r
594 edges
, faces
= [], []
595 for n
in range(theCircleRes
):
596 x
= r
*math
.sin(n
*w
+ phi0
)
597 y
= f
*r
*math
.cos(n
*w
+ phi0
)
598 v
= (center
.x
- a
*x
+ b
*y
, center
.y
- a
*y
- b
*x
, center
.z
)
602 thic
= self
.thickness
603 t_vector
= Vector((0, 0, thic
))
604 if thic
!= 0 and (toggle
& T_ThicON
):
605 thic_points
= [v
+ t_vector
for v
in points
]
607 thic_points
.extend(points
)
610 points
.extend(thic_points
)
611 faces
= [(v0
+nr
,v0
+nr
+1,pn
+v0
+nr
+1,pn
+v0
+nr
) for nr
in range(pn
)]
613 faces
[-1] = (v0
+nr
,v0
,pn
+v0
,pn
+v0
+nr
)
614 #self.drawtype = 'Mesh'
617 edges
= [(v0
+nr
,v0
+nr
+1) for nr
in range(pn
)]
619 edges
[-1] = (v0
+nr
,v0
)
623 if thic
!= 0 and (toggle
& T_ThicON
):
625 if self
.normal
!=Vector((0,0,1)):
626 ma
= getOCS(self
.normal
)
629 points
= [ma
* v
for v
in points
]
630 return ((points
, edges
, faces
, vn
))
633 # class CHatch(CEntity):
635 # 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
636 # 41 : 'scale', 47 : 'pixelsize', 52 : 'angle',
637 # 70 : 'fill', 71 : 'associativity', 75: 'style', 77 : 'double',
638 # 78 : 'numlines', 91 : 'numpaths', 98 : 'numseeds',
641 class CHatch(CEntity
):
643 CEntity
.__init
__(self
, 'HATCH', None)
645 self
.point
= Vector()
650 self
.associativity
= 0
656 self
.normal
= Vector((0,0,1))
659 # class CImage(CEntity):
660 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
661 # 11 : 'u_vector.x', 21 : 'u_vector.y', 31 : 'u_vector.z',
662 # 12 : 'v_vector.x', 22 : 'v_vector.y', 32 : 'v_vector.z',
663 # 13 : 'size.x', 23 : 'size.y', 33 : 'size.z',
664 # 14 : 'clip.x', 24 : 'clip.y', 34 : 'clip.z',
665 # 70 : 'display', 71 : 'cliptype',
667 # 280 : 'clipstate', 281 : 'brightness', 282 : 'contrast', 283 : 'fade',
668 # 340 : 'image', 360 : 'reactor'
671 class CImage(CEntity
):
673 CEntity
.__init
__(self
, 'IMAGE', None)
674 self
.insertion_point
= Vector()
675 self
.u_vector
= Vector()
676 self
.v_vector
= Vector()
688 self
.normal
= Vector((0,0,1))
691 # class CInsert(CEntity):
692 # 1 : 'attributes_follow', 2 : 'name',
693 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
694 # 41 : 'x_scale', 42 : 'y_scale', 43 : 'z_scale',
695 # 44 : 'column_spacing', 45 : 'row_spacing',
696 # 50 : 'rotation_angle', 66 : 'attributes_follow',
697 # 70 : 'column_count', 71 : 'row_count',
700 class CInsert(CEntity
):
702 CEntity
.__init
__(self
, 'INSERT', None)
703 self
.attributes_follow
= 1
705 self
.insertion_point
= Vector()
709 self
.column_spacing
= 1.0
710 self
.row_spacing
= 1.0
711 self
.rotation_angle
= 0.0
712 self
.column_count
= 1
714 self
.attributes_follow
= 0
715 self
.normal
= Vector((0,0,1))
718 CEntity
.display(self
)
719 print(self
.insertion_point
)
726 # class CLeader(CEntity):
728 # 10 : ['new_vertex(data)'], 20 : 'vertex.y', 30 : 'vertex.z',
729 # 40 : 'height', 41 : 'width',
730 # 71 : 'arrowhead', 72 : 'pathtype', 73 : 'creation',
731 # 74 : 'hookdir', 75 : 'hookline', 76 : 'numverts', 77 : 'color',
732 # 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
733 # 211 : 'horizon.x', 221 : 'horizon.y', 231 : 'horizon.z',
734 # 212 : 'offset_ins.x', 222 : 'offset_ins.y', 232 : 'offset_ins.z',
735 # 213 : 'offset_ann.x', 223 : 'offset_ann.y', 233 : 'offset_ann.z',
738 class CLeader(CEntity
):
740 CEntity
.__init
__(self
, 'LEADER', 'Mesh')
753 self
.normal
= Vector((0,0,1))
754 self
.horizon
= Vector()
755 self
.offset_ins
= Vector()
756 self
.offset_ann
= Vector()
758 def new_vertex(self
, data
):
759 self
.vertex
= Vector()
761 self
.verts
.append(self
.vertex
)
763 def build(self
, vn
=0):
766 edges
.append((vn
, vn
+1))
769 return (self
.verts
, edges
, [], vn
)
771 # class CLwPolyLine(CEntity):
772 # 10 : ['new_vertex(data)'], 20 : 'vertex.y', 30 : 'vertex.z',
773 # 38 : 'elevation', 39 : 'thickness',
774 # 40 : 'start_width', 41 : 'end_width', 42 : 'bulge', 43 : 'constant_width',
775 # 70 : 'flags', 90 : 'numverts'
778 class CLWPolyLine(CEntity
):
780 CEntity
.__init
__(self
, 'LWPOLYLINE', None)
785 self
.start_width
= 0.0
788 self
.constant_width
= 0.0
791 self
.normal
= Vector((0,0,1))
793 def new_vertex(self
, data
):
794 self
.vertex
= Vector()
796 self
.verts
.append(self
.vertex
)
798 def build(self
, vn
=0):
802 edges
.append((vn
, vn
+1))
804 if self
.flags
& PL_CLOSED
:
805 edges
[-1] = (vn
-1, v_start
)
809 if self
.normal
!=Vector((0,0,1)):
810 ma
= getOCS(self
.normal
)
813 verts
= [ma
* v
for v
in verts
]
814 return (verts
, edges
, [], vn
-1)
817 # class CLine(CEntity):
818 # 10 : 'start_point.x', 20 : 'start_point.y', 30 : 'start_point.z',
819 # 11 : 'end_point.x', 21 : 'end_point.y', 31 : 'end_point.z',
823 class CLine(CEntity
):
825 CEntity
.__init
__(self
, 'LINE', 'Mesh')
826 self
.start_point
= Vector()
827 self
.end_point
= Vector()
829 self
.normal
= Vector((0,0,1))
832 CEntity
.display(self
)
833 print(self
.start_point
)
834 print(self
.end_point
)
836 def build(self
, vn
=0):
837 points
= [self
.start_point
, self
.end_point
]
838 faces
, edges
= [], []
840 thic
= self
.thickness
841 if thic
!= 0 and (toggle
& T_ThicON
):
842 t_vector
= thic
* self
.normal
843 #print 'deb:thic_vector: ', t_vector #---------------------
844 points
.extend([v
+ t_vector
for v
in points
])
845 faces
= [[0+n
, 1+n
, 3+n
, 2+n
]]
846 self
.drawtype
= 'Mesh'
850 return((points
, edges
, faces
, vn
))
852 # class CMLine(CEntity):
853 # 10 : 'start_point.x', 20 : 'start_point.y', 30 : 'start_point.z',
854 # 11 : ['new_vertex(data)'], 21 : 'vertex.y', 31 : 'vertex.z',
855 # 12 : ['new_seg_dir(data)'], 22 : 'seg_dir.y', 32 : 'seg_dir.z',
856 # 13 : ['new_miter_dir(data)'], 23 : 'miter_dir.y', 33 : 'miter_dir.z',
857 # 40 : 'scale', 41 : 'elem_param', 42 : 'fill_param',
858 # 70 : 'justification', 71 : 'flags'
859 # 72 : 'numverts', 73 : 'numelems', 74 : 'numparam', 75 : 'numfills',
863 class CMLine(CEntity
):
865 CEntity
.__init
__(self
, 'MLINE', None)
866 self
.start_point
= Vector()
869 self
.miter_dir
= None
876 self
.justification
= 0
883 self
.normal
= Vector((0,0,1))
885 def new_vertex(self
, data
):
886 self
.vertex
= Vector()
888 self
.verts
.append(self
.vertex
)
890 def new_seg_dir(self
, data
):
891 self
.seg_dir
= Vector()
892 self
.seg_dir
.x
= data
893 self
.seg_dirs
.append(self
.seg_dir
)
895 def new_miter_dir(self
, data
):
896 self
.miter_dir
= Vector()
897 self
.miter_dir
.x
= data
898 self
.miter_dirs
.append(self
.miter_dir
)
903 # class CMText(CText):
904 # 1 : 'text', 3: 'more_text', 7 : 'style',
905 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
906 # 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
907 # 40 : 'nominal_height', 41 : 'reference_width', 42: 'width', 43 : 'height', 44 : 'line_spacing',
908 # 50 : 'rotation_angle',
909 # 71 : 'attachment_point', 72 : 'drawing_direction', 73 : 'spacing_style',
912 class CMText(CEntity
):
914 CEntity
.__init
__(self
, 'MTEXT', 'Text')
918 self
.insertion_point
= Vector()
919 self
.alignment_point
= Vector()
920 self
.nominal_height
= 1.0
921 self
.reference_width
= 1.0
924 self
.rotation_angle
= 0.0
925 self
.attachment_point
= 0
926 self
.drawing_direction
= 0
927 self
.spacing_style
= 0
928 self
.normal
= Vector((0,0,1))
931 CEntity
.display(self
)
932 print("%s %s" % (self
.text
, self
.style
))
933 print('MTEXTinsertion_point=',self
.insertion_point
)
934 print('MTEXTalignment_point=',self
.alignment_point
)
937 drawText(self
.text
, self
.insertion_point
, self
.height
, self
.width
, self
.rotation_angle
, 0.0, self
.normal
)
941 # class CPoint(CEntity):
942 # 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
943 # 39 : 'thickness', 50 : 'orientation'
946 class CPoint(CEntity
):
948 CEntity
.__init
__(self
, 'POINT', 'Mesh')
949 self
.point
= Vector()
951 self
.orientation
= 0.0
954 CEntity
.display(self
)
956 print("%.4f" % self
.orientation
)
958 def build(self
, vn
=0):
959 # draw as mesh-vertex
961 return((verts
, [], [], vn
+1))
965 # draw as empty-object
966 # loc = self.point # UNUSED
967 #bpy.ops.object.new('DXFpoint')
971 # class CPolyLine(CEntity):
972 # 1 : 'verts_follow', 2 : 'name',
973 # 10 : 'elevation.x', 20 : 'elevation.y', 30 : 'elevation.z',
974 # 40 : 'start_width', 41 : 'end_width',
975 # 66 : 'verts_follow_flag',
976 # 70 : 'flags', 71 : 'row_count', 72 : 'column_count',
977 # 73 : 'row_density', 74 : 'column_density', 75 : 'linetype',
980 class CPolyLine(CEntity
):
982 CEntity
.__init
__(self
, 'POLYLINE', 'Mesh')
984 self
.verts_follow
= 1
986 self
.elevation
= Vector()
988 self
.start_width
= 0.0
990 self
.verts_follow_flags
= 0
993 self
.column_count
= 1
994 self
.row_density
= 1.0
995 self
.column_density
= 1.0
997 self
.normal
= Vector((0,0,1))
1000 CEntity
.display(self
)
1002 for v
in self
.verts
:
1006 def build(self
, vn
=0):
1010 for vert
in self
.verts
:
1011 verts
.append(vert
.location
)
1012 lines
.append((vn
, vn
+1))
1014 if self
.flags
& PL_CLOSED
:
1015 lines
[-1] = (vn
-1, v_start
)
1018 if self
.normal
!=Vector((0,0,1)):
1019 ma
= getOCS(self
.normal
)
1021 verts
= [ma
* v
for v
in verts
]
1022 return((verts
, lines
, [], vn
-1))
1025 # class CShape(CEntity):
1027 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1029 # 40 : 'size', 41 : 'x_scale',
1030 # 50 : 'rotation_angle', 51 : 'oblique_angle',
1033 class CShape(CEntity
):
1035 CEntity
.__init
__(self
, 'SHAPE', None)
1037 self
.insertion_point
= Vector()
1038 self
.thickness
= 0.0
1041 self
.rotation_angle
= 0.0
1042 self
.oblique_angle
= 0.0
1045 CEntity
.display(self
)
1046 print("%s" % (self
.name
))
1047 print(self
.insertion_point
)
1050 # class CSpline(CEntity):
1051 # 10 : ['new_control_point(data)'], 20 : 'control_point.y', 30 : 'control_point.z',
1052 # 11 : ['new_fit_point(data)'], 21 : 'fit_point.y', 31 : 'fit_point.z',
1053 # 40 : ['new_knot_value(data)'],
1054 # 12 : 'start_tangent.x', 22 : 'start_tangent.y', 32 : 'start_tangent.z',
1055 # 13 : 'end_tangent.x', 23 : 'end_tangent.y', 33 : 'end_tangent.z',
1056 # 41 : 'weight', 42 : 'knot_tol', 43 : 'control_point_tol', 44 : 'fit_tol',
1057 # 70 : 'flag', 71 : 'degree',
1058 # 72 : 'num_knots', 73 : 'num_control_points', 74 : 'num_fit_points',
1059 # 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1062 class CSpline(CEntity
):
1064 CEntity
.__init
__(self
, 'SPLINE', 'Mesh')
1065 self
.control_points
= []
1066 self
.fit_points
= []
1067 self
.knot_values
= []
1068 self
.control_point
= None
1069 self
.fit_point
= None
1070 self
.knot_value
= None
1071 self
.start_tangent
= Vector()
1072 self
.end_tangent
= Vector()
1074 self
.knot_tol
= 1e-6
1075 self
.control_point_tol
= 1e-6
1080 self
.num_control_points
= 0
1081 self
.num_fit_points
= 0
1082 self
.thickness
= 0.0
1083 self
.normal
= Vector((0,0,1))
1085 def new_control_point(self
, data
):
1086 self
.control_point
= Vector()
1087 self
.control_point
.x
= data
1088 self
.control_points
.append(self
.control_point
)
1090 def new_fit_point(self
, data
):
1091 self
.fit_point
= Vector()
1092 self
.fit_point
.x
= data
1093 self
.fit_points
.append(self
.fit_point
)
1095 def new_knot_value(self
, data
):
1096 self
.knot_value
= data
1097 self
.knot_values
.append(self
.knot_value
)
1100 #not testet yet (migius)
1101 CEntity
.display(self
)
1103 for p
in self
.control_points
:
1106 for p
in self
.fit_points
:
1109 for v
in self
.knot_values
:
1112 def build(self
, vn
=0):
1115 for vert
in self
.control_points
:
1117 lines
.append((vn
, vn
+1))
1120 return((verts
, lines
, [], vn
))
1124 # class CSolid(CEntity):
1125 # 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1126 # 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1127 # 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1128 # 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1132 class CSolid(CEntity
):
1134 CEntity
.__init
__(self
, 'SOLID', 'Mesh')
1135 self
.point0
= Vector()
1136 self
.point1
= Vector()
1137 self
.point2
= Vector()
1138 self
.point3
= Vector()
1139 self
.normal
= Vector((0,0,1))
1140 self
.thickness
= 0.0
1143 CEntity
.display(self
)
1149 def build(self
, vn
=0):
1150 points
, edges
, faces
= [],[],[]
1151 if self
.point2
== self
.point3
:
1152 points
= [self
.point0
, self
.point1
, self
.point2
]
1154 points
= [self
.point0
, self
.point1
, self
.point2
, self
.point3
]
1158 thic
= self
.thickness
1159 t_vector
= Vector((0, 0, thic
))
1160 if thic
!= 0 and (toggle
& T_ThicON
):
1161 thic_points
= [v
+ t_vector
for v
in points
]
1163 thic_points
.extend(points
)
1164 points
= thic_points
1166 points
.extend(thic_points
)
1169 faces
= [[0,1,3,2], [4,6,7,5], [0,4,5,1],
1170 [1,5,7,3], [3,7,6,2], [2,6,4,0]]
1172 faces
= [[0,1,2], [3,5,4], [0,3,4,1], [1,4,5,2], [2,5,3,0]]
1173 elif pn
== 2: faces
= [[0,1,3,2]]
1176 if pn
== 4: faces
= [[0,2,3,1]]
1177 elif pn
== 3: faces
= [[0,2,1]]
1180 self
.drawtype
= 'Mesh'
1182 if self
.normal
!=Vector((0,0,1)):
1183 ma
= getOCS(self
.normal
)
1185 points
= [ma
* v
for v
in points
]
1186 return((points
, edges
, faces
, vn
))
1189 # class CText(CEntity):
1190 # 1 : 'text', 7 : 'style',
1191 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1192 # 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1193 # 40 : 'height', 41 : 'x_scale',
1194 # 50 : 'rotation_angle', 51 : 'oblique_angle',
1195 # 71 : 'flags', 72 : 'horizontal_justification', 73 : 'vertical_justification',
1198 class CText(CEntity
):
1200 CEntity
.__init
__(self
, 'TEXT', 'Text')
1203 self
.insertion_point
= Vector()
1204 self
.alignment_point
= Vector()
1207 self
.rotation_angle
= 0.0
1208 self
.oblique_angle
= 0.0
1210 self
.horizontal_justification
= 0.0
1211 self
.vertical_justification
= 0.0
1212 self
.thickness
= 0.0
1213 self
.normal
= Vector((0,0,1))
1216 CEntity
.display(self
)
1217 print("%s %s" % (self
.text
, self
.style
))
1218 print(self
.insertion_point
)
1219 print(self
.alignment_point
)
1222 drawText(self
.text
, self
.insertion_point
, self
.height
, self
.x_scale
, self
.rotation_angle
, self
.oblique_angle
, self
.normal
)
1226 def drawText(text
, loc
, size
, spacing
, angle
, shear
, normal
=Vector((0,0,1))):
1227 #print('angle_deg=',angle)
1228 bpy
.ops
.object.text_add(
1230 enter_editmode
=False,
1232 #rotation=(0, 0, angle), #need radians here
1234 cu
= bpy
.context
.object.data
1236 cu
.size
= size
#up 2.56
1237 cu
.space_word
= spacing
#up 2.56
1239 if angle
!=0.0 or normal
!=Vector((0,0,1)):
1240 obj
= bpy
.context
.object
1241 transform(normal
, angle
, obj
)
1245 # class CTolerance(CEntity):
1247 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1248 # 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1251 class CTolerance(CEntity
):
1253 CEntity
.__init
__(self
, 'TOLERANCE', None)
1255 self
.insertion_point
= Vector()
1256 self
.direction
= Vector()
1259 # class CTrace(CEntity):
1260 # 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1261 # 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1262 # 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1263 # 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1267 class CTrace(CEntity
):
1269 CEntity
.__init
__(self
, 'TRACE', 'Mesh')
1270 self
.point0
= Vector()
1271 self
.point1
= Vector()
1272 self
.point2
= Vector()
1273 self
.point3
= Vector()
1274 self
.normal
= Vector((0,0,1))
1275 self
.thickness
= 0.0
1278 CEntity
.display(self
)
1284 def build(self
, vn
=0):
1285 points
, edges
, faces
= [],[],[]
1286 if self
.point2
== self
.point3
:
1287 points
= [self
.point0
, self
.point2
, self
.point1
]
1289 points
= [self
.point0
, self
.point2
, self
.point1
, self
.point3
]
1292 thic
= self
.thickness
1293 t_vector
= Vector((0, 0, thic
))
1294 if thic
!= 0 and (toggle
& T_ThicON
):
1295 thic_points
= [v
+ t_vector
for v
in points
]
1297 thic_points
.extend(points
)
1298 points
= thic_points
1300 points
.extend(thic_points
)
1303 faces
= [[0,1,3,2], [4,6,7,5], [0,4,5,1],
1304 [1,5,7,3], [3,7,6,2], [2,6,4,0]]
1306 faces
= [[0,1,2], [3,5,4], [0,3,4,1], [1,4,5,2], [2,5,3,0]]
1307 elif pn
== 2: faces
= [[0,1,3,2]]
1310 if pn
== 4: faces
= [[0,2,3,1]]
1311 elif pn
== 3: faces
= [[0,2,1]]
1314 self
.drawtype
= 'Mesh'
1315 if self
.normal
!=Vector((0,0,1)):
1316 ma
= getOCS(self
.normal
)
1318 points
= [ma
* v
for v
in points
]
1319 return ((points
, edges
, faces
, vn
))
1322 # class CVertex(CEntity):
1323 # 10 : 'location.x', 20 : 'location.y', 30 : 'location.z',
1324 # 40 : 'start_width', 41 : 'end_width', 42 : 'bulge',
1327 # 71 : 'index1', 72 : 'index2', 73 : 'index3', 74 : 'index4',
1330 class CVertex(CEntity
):
1332 CEntity
.__init
__(self
, 'VERTEX', None)
1333 self
.location
= Vector()
1334 self
.start_width
= 0.0
1335 self
.end_width
= 0.0
1347 # class CViewPort(CEntity):
1348 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1349 # 12 : 'view_center.x', 22 : 'view_center.y', 32 : 'view_center.z',
1350 # 13 : 'snap_base.x', 23 : 'snap_base.y', 33 : 'snap_base.z',
1351 # 14 : 'snap_spacing.x', 24 : 'snap_spacing.y', 34 : 'snap_spacing.z',
1352 # 15 : 'grid_spacing.x', 25 : 'grid_spacing.y', 35 : 'grid_spacing.z',
1353 # 16 : 'view_direction.x', 26 : 'view_direction.y', 36 : 'view_direction.z',
1354 # 40 : 'width', 41 : 'height',
1355 # 68 : 'status', 69 : 'id',
1358 class CViewPort(CEntity
):
1360 CEntity
.__init
__(self
, 'VIEWPORT', None)
1361 self
.center
= Vector()
1362 self
.view_center
= Vector()
1363 self
.snap_base
= Vector()
1364 self
.snap_spacing
= Vector()
1365 self
.grid_spacing
= Vector()
1366 self
.view_direction
= Vector()
1377 # class CWipeOut(CEntity):
1378 # 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1379 # 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1382 class CWipeOut(CEntity
):
1384 CEntity
.__init
__(self
, 'WIPEOUT', None)
1385 self
.point
= Vector()
1386 self
.direction
= Vector()
1391 WORLDX
= Vector((1.0,0.0,0.0))
1392 WORLDY
= Vector((0.0,1.0,0.0))
1393 WORLDZ
= Vector((0.0,0.0,1.0))
1396 def getOCS(az
): #-----------------------------------------------------------------
1397 """An implimentation of the Arbitrary Axis Algorithm.
1399 #decide if we need to transform our coords
1400 #if az[0] == 0 and az[1] == 0:
1401 if abs(az
.x
) < 0.00001 and abs(az
.y
) < 0.00001:
1405 return Matrix((-WORLDX
, WORLDY
*1, -WORLDZ
)).transposed()
1407 cap
= 0.015625 # square polar cap value (1/64.0)
1408 if abs(az
.x
) < cap
and abs(az
.y
) < cap
:
1409 ax
= WORLDY
.cross(az
)
1411 ax
= WORLDZ
.cross(az
)
1415 # Matrices are now constructed from rows, transpose to make the rows into cols
1416 return Matrix((ax
, ay
, az
)).transposed()
1420 def transform(normal
, rotation
, obj
): #--------------------------------------------
1421 """Use the calculated ocs to determine the objects location/orientation in space.
1424 o
= Vector(obj
.location
)
1425 ma_new
= getOCS(normal
)
1432 rmat
= Matrix
.Rotation(radians(rotation
), 4, 'Z')
1435 obj
.matrix_world
= ma
1439 DxfEntityAttributes
= {
1441 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1442 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1443 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1444 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1449 1 : 'data', 3 : 'more', 70 : 'version',
1452 'ACAD_PROXY_ENTITY' : {
1454 90 : 'id', 91 : 'class', 92 : 'graphics_size', 93 : 'entity_size', 95: 'format',
1455 310 : 'data', 330 : 'id1', 340 : 'id2', 350 : 'id3', 360 : 'id4',
1459 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1461 50 : 'start_angle', 51 : 'end_angle',
1463 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1466 'ARCALIGNEDTEXT' : {
1467 1 : 'text', 2 : 'font', 3 : 'bigfont', 7 : 'style',
1468 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1469 40 : 'radius', 41 : 'width', 42 : 'height', 43 : 'spacing',
1470 44 : 'offset', 45 : 'right_offset', 46 : 'left_offset',
1471 50 : 'start_angle', 51 : 'end_angle',
1472 70 : 'order', 71 : 'direction', 72 : 'alignment', 73 : 'side',
1473 74 : 'bold', 75 : 'italic', 76 : 'underline',
1474 77 : 'character_set', 78 : 'pitch', 79 : 'fonttype',
1476 280 : 'wizard', 330 : 'id'
1480 1 : 'text', 2 : 'tag', 3 : 'prompt', 7 : 'style',
1481 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1482 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1483 40 : 'height', 41 : 'x_scale',
1484 50 : 'rotation_angle', 51 : 'oblique_angle',
1485 70 : 'flags', 71 : 'text_generation_flags',
1486 72 : 'horizontal_justification', 74 : 'vertical_justification',
1491 1 : 'text', 2 : 'tag', 3 : 'prompt', 7 : 'style',
1492 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1493 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1494 40 : 'height', 41 : 'x_scale',
1495 50 : 'rotation_angle', 51 : 'oblique_angle',
1496 70 : 'flags', 73 : 'length',
1497 71 : 'text_generation_flags', 72 : 'horizontal_justification', 74 : 'vertical_justification',
1501 1 : 'xref', 2 : 'name', 3 : 'also_name',
1502 10 : 'base_point.x', 20 : 'base_point.y', 30 : 'base_point.z',
1503 40 : 'size', 41 : 'x_scale',
1504 50 : 'rotation_angle', 51 : 'oblique_angle',
1509 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1512 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1516 1 : 'text', 2 : 'name', 3 : 'style',
1517 10 : 'def_point.x', 20 : 'def_point.y', 30 : 'def_point.z',
1518 11 : 'mid_point.x', 21 : 'mid_point.y', 31 : 'mid_point.z',
1519 12 : 'vector.x', 22 : 'vector.y', 32 : 'vector.z',
1520 13 : 'def_point2.x', 23 : 'def_point2.y', 33 : 'def_point2.z',
1521 14 : 'vector2.x', 24 : 'vector2.y', 34 : 'vector2.z',
1522 15 : 'vector3.x', 25 : 'vector3.y', 35 : 'vector3.z',
1523 16 : 'vector4.x', 26 : 'vector4.y', 36 : 'vector4.z',
1528 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1529 11 : 'end_point.x', 21 : 'end_point.y', 31 : 'end_point.z',
1530 40 : 'ratio', 41 : 'start', 42 : 'end',
1532 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1537 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1538 41 : 'scale', 47 : 'pixelsize', 52 : 'angle',
1539 70 : 'fill', 71 : 'associativity', 75: 'style', 77 : 'double',
1540 78 : 'numlines', 91 : 'numpaths', 98 : 'numseeds',
1541 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1545 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1546 11 : 'u_vector.x', 21 : 'u_vector.y', 31 : 'u_vector.z',
1547 12 : 'v_vector.x', 22 : 'v_vector.y', 32 : 'v_vector.z',
1548 13 : 'size.x', 23 : 'size.y', 33 : 'size.z',
1549 14 : 'clip.x', 24 : 'clip.y', 34 : 'clip.z',
1550 70 : 'display', 71 : 'cliptype',
1552 280 : 'clipstate', 281 : 'brightness', 282 : 'contrast', 283 : 'fade',
1553 340 : 'image', 360 : 'reactor',
1557 1 : 'attributes_follow', 2 : 'name',
1558 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1559 41 : 'x_scale', 42 : 'y_scale', 43 : 'z_scale',
1560 44 : 'column_spacing', 45 : 'row_spacing',
1561 50 : 'rotation_angle', 66 : 'attributes_follow',
1562 70 : 'column_count', 71 : 'row_count',
1563 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1568 10 : ['new_vertex(data)'], 20 : 'vertex.y', 30 : 'vertex.z',
1569 40 : 'height', 41 : 'width',
1570 71 : 'arrowhead', 72 : 'pathtype', 73 : 'creation',
1571 74 : 'hookdir', 75 : 'hookline', 76 : 'numverts', 77 : 'color',
1572 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1573 211 : 'horizon.x', 221 : 'horizon.y', 231 : 'horizon.z',
1574 212 : 'offset_ins.x', 222 : 'offset_ins.y', 232 : 'offset_ins.z',
1575 213 : 'offset_ann.x', 223 : 'offset_ann.y', 233 : 'offset_ann.z',
1579 10 : 'start_point.x', 20 : 'start_point.y', 30 : 'start_point.z',
1580 11 : 'end_point.x', 21 : 'end_point.y', 31 : 'end_point.z',
1582 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1586 10 : ['new_vertex(data)'], 20 : 'vertex.y', 30 : 'vertex.z',
1587 38 : 'elevation', 39 : 'thickness',
1588 40 : 'start_width', 41 : 'end_width', 42 : 'bulge', 43 : 'constant_width',
1589 70 : 'flags', 90 : 'numverts',
1590 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1594 10 : 'start_point.x', 20 : 'start_point.y', 30 : 'start_point.z',
1595 11 : ['new_vertex(data)'], 21 : 'vertex.y', 31 : 'vertex.z',
1596 12 : ['new_seg_dir(data)'], 22 : 'seg_dir.y', 32 : 'seg_dir.z',
1597 13 : ['new_miter_dir(data)'], 23 : 'miter_dir.y', 33 : 'miter_dir.z',
1599 40 : 'scale', 41 : 'elem_param', 42 : 'fill_param',
1600 70 : 'justification', 71 : 'flags',
1601 72 : 'numverts', 73 : 'numelems', 74 : 'numparam', 75 : 'numfills',
1603 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1607 1 : 'text', 3: 'more_text', 7 : 'style',
1608 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1609 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1610 40 : 'nominal_height', 41 : 'reference_width', 42: 'width', 43 : 'height', 44 : 'line_spacing',
1611 50 : 'rotation_angle',
1612 71 : 'attachment_point', 72 : 'drawing_direction', 73 : 'spacing_style',
1613 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1617 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1618 39 : 'thickness', 50 : 'orientation',
1622 1 : 'verts_follow', 2 : 'name',
1623 10 : 'elevation.x', 20 : 'elevation.y', 30 : 'elevation.z',
1625 40 : 'start_width', 41 : 'end_width',
1626 66 : 'verts_follow_flag',
1627 70 : 'flags', 71 : 'row_count', 72 : 'column_count',
1628 73 : 'row_density', 74 : 'column_density', 75 : 'linetype',
1629 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1633 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1634 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1638 1 : 'text', 7 : 'style',
1639 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1642 50 : 'rotation_angle',
1644 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1649 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1651 40 : 'size', 41 : 'x_scale',
1652 50 : 'rotation_angle', 51 : 'oblique_angle',
1657 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1658 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1659 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1660 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1662 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1666 10 : ['new_control_point(data)'], 20 : 'control_point.y', 30 : 'control_point.z',
1667 11 : ['new_fit_point(data)'], 21 : 'fit_point.y', 31 : 'fit_point.z',
1668 40 : ['new_knot_value(data)'],
1669 12 : 'start_tangent.x', 22 : 'start_tangent.y', 32 : 'start_tangent.z',
1670 13 : 'end_tangent.x', 23 : 'end_tangent.y', 33 : 'end_tangent.z',
1672 41 : 'weight', 42 : 'knot_tol', 43 : 'control_point_tol', 44 : 'fit_tol',
1673 70 : 'flag', 71 : 'degree',
1674 72 : 'num_knots', 73 : 'num_control_points', 74 : 'num_fit_points',
1675 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1679 1 : 'text', 7 : 'style',
1680 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1681 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1682 40 : 'height', 41 : 'x_scale',
1683 50 : 'rotation_angle', 51 : 'oblique_angle',
1684 71 : 'flags', 72 : 'horizontal_justification', 73 : 'vertical_justification',
1685 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1690 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1691 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1695 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1696 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1697 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1698 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1700 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1704 10 : 'location.x', 20 : 'location.y', 30 : 'location.z',
1705 40 : 'start_width', 41 : 'end_width', 42 : 'bulge',
1708 71 : 'index1', 72 : 'index2', 73 : 'index3', 74 : 'index4',
1712 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1713 12 : 'view_center.x', 22 : 'view_center.y', 32 : 'view_center.z',
1714 13 : 'snap_base.x', 23 : 'snap_base.y', 33 : 'snap_base.z',
1715 14 : 'snap_spacing.x', 24 : 'snap_spacing.y', 34 : 'snap_spacing.z',
1716 15 : 'grid_spacing.x', 25 : 'grid_spacing.y', 35 : 'grid_spacing.z',
1717 16 : 'view_direction.x', 26 : 'view_direction.y', 36 : 'view_direction.z',
1718 40 : 'width', 41 : 'height',
1719 68 : 'status', 69 : 'id',
1723 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1724 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1736 PL_CURVE_FIT_VERTS
= 0x02
1737 PL_SPLINE_FIT_VERTS
= 0x04
1738 PL_3D_POLYLINE
= 0x08
1739 PL_3D_POLYGON_MESH
= 0x10
1740 PL_CLOSED_IN_N_DIR
= 0x20
1741 PL_POLYFACE_MESH
= 0x40
1742 PL_CONTINUOUS
= 0x80
1746 VX_EXTRA_FLAG_CREATED
= 0x01
1747 VX_CURVE_FIT_TANGENT_DEFINED
= 0x02
1748 VX_SPLINE_VERTEX_CREATED
= 0x08
1749 VX_SPLINE_FRAME_CONTROL_POINT
= 0x10
1750 VX_3D_POLYLINE_VERTEX
= 0x20
1751 VX_3D_POLYGON_MESH_VERTEX
= 0x40
1752 VX_POLYFACE_MESH_VERTEX
= 0x80
1756 F3D_EDGE0_INVISIBLE
= 0x01
1757 F3D_EDGE1_INVISIBLE
= 0x02
1758 F3D_EDGE2_INVISIBLE
= 0x04
1759 F3D_EDGE3_INVISIBLE
= 0x08
1762 # readDxfFile(filePath):
1765 def readDxfFile(fileName
):
1766 global toggle
, theCodec
1768 print( "Opening DXF file "+ fileName
)
1770 # fp= open(fileName, "rU")
1771 fp
= codecs
.open(fileName
, "r", encoding
=theCodec
)
1783 if toggle
& T_Verbose
:
1784 print("%4d: %4d %s" % (no
, code
, word
))
1814 statements
.append((code
,data
))
1818 statements
.reverse()
1822 (code
,data
) = statements
.pop()
1824 if data
== 'SECTION':
1825 section
= CSection()
1828 if data
== 'HEADER':
1829 parseHeader(section
, statements
, handles
)
1831 elif data
== 'CLASSES':
1832 parseClasses(section
, statements
, handles
)
1834 elif data
== 'TABLES':
1835 parseTables(section
, statements
, handles
)
1837 elif data
== 'BLOCKS':
1838 parseBlocks(section
, statements
, handles
)
1840 elif data
== 'ENTITIES':
1841 parseEntities(section
, statements
, handles
)
1843 elif data
== 'OBJECTS':
1844 parseObjects(section
, statements
, handles
)
1845 elif data
== 'THUMBNAILIMAGE':
1846 parseThumbnail(section
, statements
, handles
)
1847 sections
[data
] = section
1851 raise NameError("Unexpected code in SECTION context: %d %s" % (code
,data
))
1853 if toggle
& T_Verbose
:
1854 for (typ
,section
) in sections
.items():
1874 def parseHeader(section
, statements
, handles
):
1876 (code
,data
) = statements
.pop()
1878 if data
== 'ENDSEC':
1892 # <class dxf record>
1907 def parseClasses(section
, statements
, handles
):
1909 (code
,data
) = statements
.pop()
1911 if data
== 'ENDSEC':
1938 # AcDbSymbolTableRecord
1950 # APPID (application identification table)
1952 # BLOCK_RECORD (block reference table)
1954 # DIMSTYLE (dimension style table)
1956 # LAYER (layer table)
1958 # LTYPE (linetype table)
1960 # STYLE (text style table)
1962 # UCS (User Coordinate System table)
1966 # VPORT (viewport configuration table)
1969 def parseTables(section
, statements
, handles
):
1971 section
.data
= tables
1973 (code
,data
) = statements
.pop()
1975 if data
== 'ENDSEC':
1979 elif data == 'TABLE':
1981 tables.append(table)
1983 elif data == 'ENDTAB':
1986 elif data == table.type:
1989 tables.append(table)
1995 handles[word] = table
1999 table.subclass = word
2001 table.nEntries = int(word)
2051 def parseBlocks(section
, statements
, handles
):
2053 (code
,data
) = statements
.pop()
2055 if data
== 'ENDSEC':
2070 # <pointer to owner>
2084 Ignorables
= ['DIMENSION', 'TEXT', 'VIEWPORT']
2087 '3DFACE': 'C3dFace()',
2088 '3DSOLID': 'C3dSolid()',
2089 'ACAD_PROXY_ENTITY': 'CAcadProxyEntity()',
2090 'ACAD_ZOMBIE_ENTITY': 0,
2092 'ARCALIGNEDTEXT': 'CArcAlignedText()',
2093 'ATTDEF': 'CAttdef()',
2094 'ATTRIB': 'CAttrib()',
2096 'CIRCLE': 'CCircle()',
2097 'DIMENSION': 'CDimension()',
2098 'ELLIPSE': 'CEllipse()',
2099 'HATCH': 'CHatch()',
2100 'IMAGE': 'CImage()',
2101 'INSERT': 'CInsert()',
2102 'LEADER': 'CLeader()',
2104 'LWPOLYLINE': 'CLWPolyLine()',
2105 'MLINE': 'CMLine()',
2106 'MTEXT': 'CMText()',
2109 'POINT': 'CPoint()',
2110 'POLYLINE': 'CPolyLine()',
2115 'SHAPE': 'CShape()',
2116 'SOLID': 'CSolid()',
2117 'SPLINE': 'CSpline()',
2119 'TOLERANCE': 'CTolerance()',
2120 'TRACE': 'CTrace()',
2121 'VERTEX': 'CVertex()',
2122 'VIEWPORT': 'CViewPort()',
2123 'WIPEOUT': 'CWipeOut()',
2124 'XLINE': 'CXLine()',
2127 def parseEntities(section
, statements
, handles
):
2129 section
.data
= entities
2131 (code
,data
) = statements
.pop()
2132 if toggle
& T_Verbose
:
2133 print("ent", code
,data
)
2136 if data
in Ignorables
:
2142 creator
= ClassCreators
[data
]
2147 entity
= eval(creator
)
2148 elif data
== 'ENDSEC':
2153 if data
== 'POLYLINE':
2154 verts
= entity
.verts
2155 elif data
== 'VERTEX':
2156 verts
.append(entity
)
2158 if data
== 'SEQEND':
2164 entities
.append(entity
)
2165 attributes
= DxfEntityAttributes
[data
]
2167 raise NameError("Unknown data %s" % data
)
2172 expr
= getAttribute(attributes
, code
)
2176 expr
= getAttribute(DxfCommonAttributes
, code
)
2179 elif code
>= 1000 or ignore
:
2181 elif toggle
& T_Debug
:
2182 raise NameError("Unknown code %d for %s" % (code
, entity
.type))
2186 def getAttribute(attributes
, code
):
2188 ext
= attributes
[code
]
2189 if type(ext
) == str:
2190 expr
= "entity.%s = data" % ext
2193 expr
= "entity.%s" % name
2225 def parseObjects(data
, statements
, handles
):
2227 (code
,data
) = statements
.pop()
2229 if data
== 'ENDSEC':
2239 # 28000000B40000005500000001001800000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
2241 # FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
2247 def parseThumbnail(section
, statements
, handles
):
2248 """ Just skip these """
2250 (code
,data
) = statements
.pop()
2252 if data
== 'ENDSEC':
2258 # buildGeometry(entities):
2259 # addMesh(name, verts, edges, faces):
2262 def buildGeometry(entities
):
2263 try: bpy
.ops
.object.mode_set(mode
='OBJECT')
2274 for ent
in entities
:
2275 if ent
.drawtype
in {'Mesh', 'Curve'}:
2276 (verts
, edges
, faces
, vn
) = ent
.build()
2277 if not toggle
& T_DrawOne
:
2278 drawGeometry(verts
, edges
, faces
)
2282 for i
,f
in enumerate(faces
):
2284 faces
[i
] = tuple(it
+f_vn
for it
in f
)
2285 for i
,e
in enumerate(edges
):
2286 edges
[i
] = tuple(it
+f_vn
for it
in e
)
2287 f_verts
.extend(verts
)
2288 f_edges
.extend(edges
)
2289 f_faces
.extend(faces
)
2292 for i
,e
in enumerate(edges
):
2293 edges
[i
] = tuple(it
+e_vn
for it
in e
)
2294 e_verts
.extend(verts
)
2295 e_edges
.extend(edges
)
2298 v_verts
.extend(verts
)
2303 if toggle
& T_DrawOne
:
2304 drawGeometry(f_verts
, f_edges
, f_faces
)
2305 drawGeometry(e_verts
, e_edges
)
2306 drawGeometry(v_verts
)
2310 def drawGeometry(verts
, edges
=[], faces
=[]):
2312 if edges
and (toggle
& T_Curves
):
2313 print ('draw Curve')
2314 cu
= bpy
.data
.curves
.new('DXFlines', 'CURVE')
2315 cu
.dimensions
= '3D'
2316 buildSplines(cu
, verts
, edges
)
2317 ob
= addObject('DXFlines', cu
)
2319 #for v in verts: print(v)
2320 #print ('draw Mesh with %s vertices' %(len(verts)))
2321 #for e in edges: print(e)
2322 #print ('draw Mesh with %s edges' %(len(edges)))
2323 #for f in faces: print(f)
2324 #print ('draw Mesh with %s faces' %(len(faces)))
2325 me
= bpy
.data
.meshes
.new('DXFmesh')
2326 me
.from_pydata(verts
, edges
, faces
)
2327 ob
= addObject('DXFmesh', me
)
2333 def buildSplines(cu
, verts
, edges
):
2336 (v0
,v1
) = edges
.pop()
2338 newPoints
= [tuple(verts
[v0
]),tuple(verts
[v1
])]
2339 for (v0
,v1
) in edges
:
2341 newPoints
.append(tuple(verts
[v1
]))
2343 #print ('newPoints=', newPoints)
2344 point_list
.append(newPoints
)
2345 newPoints
= [tuple(verts
[v0
]),tuple(verts
[v1
])]
2347 point_list
.append(newPoints
)
2348 for points
in point_list
:
2349 spline
= cu
.splines
.new('POLY')
2350 #spline = cu.splines.new('BEZIER')
2351 #spline.use_endpoint_u = True
2353 #spline.resolution_u = 1
2354 #spline.bezier_points.add(2)
2356 spline
.points
.add(len(points
)-1)
2357 #spline.points.foreach_set('co', points)
2358 for i
,p
in enumerate(points
):
2359 spline
.points
[i
].co
= (p
[0],p
[1],p
[2],0)
2361 #print ('spline.type=', spline.type)
2362 #print ('spline number=', len(cu.splines))
2365 def addObject(name
, data
):
2366 ob
= bpy
.data
.objects
.new(name
, data
)
2367 scn
= bpy
.context
.scene
2368 scn
.objects
.link(ob
)
2372 def removeDoubles(ob
):
2373 global theMergeLimit
2374 if toggle
& T_Merge
:
2375 scn
= bpy
.context
.scene
2376 scn
.objects
.active
= ob
2377 bpy
.ops
.object.mode_set(mode
='EDIT')
2378 bpy
.ops
.mesh
.remove_doubles(threshold
=theMergeLimit
)
2379 bpy
.ops
.object.mode_set(mode
='OBJECT')
2384 # clearScene(context):
2389 scn
= bpy
.context
.scene
2390 print("clearScene %s %s" % (toggle
& T_NewScene
, scn
))
2391 if not toggle
& T_NewScene
:
2394 for ob
in scn
.objects
:
2395 if ob
.type in ["MESH", "CURVE", "TEXT"]:
2396 scn
.objects
.active
= ob
2397 bpy
.ops
.object.mode_set(mode
='OBJECT')
2398 scn
.objects
.unlink(ob
)
2403 # readAndBuildDxfFile(filepath):
2406 def readAndBuildDxfFile(filepath
):
2407 fileName
= os
.path
.expanduser(filepath
)
2409 (shortName
, ext
) = os
.path
.splitext(fileName
)
2410 #print("filepath: ", filepath)
2411 #print("fileName: ", fileName)
2412 #print("shortName: ", shortName)
2413 if ext
.lower() != ".dxf":
2414 print("Error: Not a dxf file: " + fileName
)
2416 if toggle
& T_NewScene
:
2418 if 0: # how to switch to the new scene?? (migius)
2419 new_scn
= bpy
.data
.scenes
.new(shortName
[-20:])
2420 #new_scn.layers = (1<<20) -1
2421 #new_scn_name = new_scn.name # UNUSED
2422 bpy
.data
.screens
.scene
= new_scn
2423 #print("newScene: %s" % (new_scn))
2424 sections
= readDxfFile(fileName
)
2425 print("Building geometry")
2426 buildGeometry(sections
['ENTITIES'].data
)
2429 print("Error: Not a dxf file: " + filepath
)
2437 from bpy
.props
import *
2439 def tripleList(list1
):
2442 list3
.append((elt
,elt
,elt
))
2445 class IMPORT_OT_autocad_dxf(bpy
.types
.Operator
):
2446 """Import from DXF file format (.dxf)"""
2447 bl_idname
= "import_scene.autocad_dxf"
2448 bl_description
= 'Import from DXF file format (.dxf)'
2449 bl_label
= "Import DXF" +' v.'+ __version__
2450 bl_space_type
= "PROPERTIES"
2451 bl_region_type
= "WINDOW"
2452 bl_options
= {'UNDO'}
2454 filepath
= StringProperty(
2455 subtype
='FILE_PATH',
2457 new_scene
= BoolProperty(
2458 name
="Replace scene",
2459 description
="Replace scene",
2460 default
=toggle
& T_NewScene
,
2462 #~ new_scene = BoolProperty(
2463 #~ name="New scene",
2464 #~ description="Create new scene",
2465 #~ default=toggle & T_NewScene,
2467 curves
= BoolProperty(
2469 description
="Draw entities as curves",
2470 default
=toggle
& T_Curves
,
2472 thic_on
= BoolProperty(
2474 description
="Support THICKNESS",
2475 default
=toggle
& T_ThicON
,
2477 merge
= BoolProperty(
2478 name
="Remove doubles",
2479 description
="Merge coincident vertices",
2480 default
=toggle
& T_Merge
,
2482 mergeLimit
= FloatProperty(
2484 description
="Merge limit * 0.0001",
2485 default
=theMergeLimit
* 1e4
,
2491 draw_one
= BoolProperty(
2493 description
="Draw all into one mesh object",
2494 default
=toggle
& T_DrawOne
,
2496 circleResolution
= IntProperty(
2497 name
="Circle resolution",
2498 description
="Circle/Arc are approximated with this factor",
2499 default
=theCircleRes
,
2505 codecs
= tripleList(['iso-8859-15', 'utf-8', 'ascii'])
2506 codec
= EnumProperty(name
="Codec",
2507 description
="Codec",
2511 debug
= BoolProperty(
2513 description
="Unknown DXF-codes generate errors",
2514 default
=toggle
& T_Debug
,
2516 verbose
= BoolProperty(
2518 description
="Print debug info",
2519 default
=toggle
& T_Verbose
,
2523 def draw(self
, context
):
2524 layout0
= self
.layout
2525 #layout0.enabled = False
2527 #col = layout0.column_flow(2,align=True)
2528 layout
= layout0
.box()
2529 col
= layout
.column()
2530 #col.prop(self, 'KnotType') waits for more knottypes
2531 #col.label(text="import Parameters")
2532 #col.prop(self, 'replace')
2533 col
.prop(self
, 'new_scene')
2535 row
= layout
.row(align
=True)
2536 row
.prop(self
, 'curves')
2537 row
.prop(self
, 'circleResolution')
2539 row
= layout
.row(align
=True)
2540 row
.prop(self
, 'merge')
2542 row
.prop(self
, 'mergeLimit')
2544 row
= layout
.row(align
=True)
2546 row
.prop(self
, 'draw_one')
2547 row
.prop(self
, 'thic_on')
2549 col
= layout
.column()
2550 col
.prop(self
, 'codec')
2552 row
= layout
.row(align
=True)
2553 row
.prop(self
, 'debug')
2555 row
.prop(self
, 'verbose')
2557 def execute(self
, context
):
2558 global toggle
, theMergeLimit
, theCodec
, theCircleRes
2559 O_Merge
= T_Merge
if self
.merge
else 0
2560 #O_Replace = T_Replace if self.replace else 0
2561 O_NewScene
= T_NewScene
if self
.new_scene
else 0
2562 O_Curves
= T_Curves
if self
.curves
else 0
2563 O_ThicON
= T_ThicON
if self
.thic_on
else 0
2564 O_DrawOne
= T_DrawOne
if self
.draw_one
else 0
2565 O_Debug
= T_Debug
if self
.debug
else 0
2566 O_Verbose
= T_Verbose
if self
.verbose
else 0
2568 toggle
= O_Merge | O_DrawOne | O_NewScene | O_Curves | O_ThicON | O_Debug | O_Verbose
2569 theMergeLimit
= self
.mergeLimit
*1e-4
2570 theCircleRes
= self
.circleResolution
2571 theCodec
= self
.codec
2573 readAndBuildDxfFile(self
.filepath
)
2576 def invoke(self
, context
, event
):
2577 wm
= context
.window_manager
2578 wm
.fileselect_add(self
)
2579 return {'RUNNING_MODAL'}
2582 def menu_func(self
, context
):
2583 self
.layout
.operator(IMPORT_OT_autocad_dxf
.bl_idname
, text
="Autocad (.dxf)")
2587 bpy
.utils
.register_module(__name__
)
2589 bpy
.types
.INFO_MT_file_import
.append(menu_func
)
2593 bpy
.utils
.unregister_module(__name__
)
2595 bpy
.types
.INFO_MT_file_import
.remove(menu_func
)
2598 if __name__
== "__main__":