View Full Version : Polylines to 3D-polylines
Tyke
14th Jun 2006, 04:49 pm
I receive dxf files from third party software which includes polylines. The group 30 code (Z coordinate) is always 0.000.
When I have finished my side of things I send the dxf file on to someone else who then reads the dxf file into GNet (Intergraph GIS).
He then complains he cannot process the polylines as the are lightweight polylines and he needs 3D polylines.
Is there a way that I can change the polylines into 3D polylines?
scj
14th Jun 2006, 06:16 pm
Try out PEDIT3D from www.black-cad.de
Regards
Jochen
Tyke
15th Jun 2006, 10:54 am
It does what I want, up to a point.
I need the new 3D-Polyline to inherit all the properties of the old polyline (layer, colour, linetype, etc) and afterwards to automatically delete the old polyline.
I'm looking towards a VBA solution that can be applied globally to a drawing with lots of polylines.
Thanks Jochen
Tyke
kpblc
15th Jun 2006, 11:58 am
Try to use this:
(defun c:lwp-3dp (/ adoc selset vla_3dpoly pt_lst)
(defun loc:kpblc-conv-2d-to-3d (lst / res item counter)
(setq counter 0)
(while (setq item (nth counter lst))
(setq res (append res (list (nth counter lst) (nth (1+ counter) lst) 0.))
counter (+ 2 counter)
) ;_ end of setq
) ;_ end of while
res
) ;_ end of defun
(vl-load-com)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(vla-startundomark adoc)
(if (setq selset (ssget "_X" '((0 . "LWPOLYLINE"))))
(foreach item (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex selset)))
) ;_ end of mapcar
(setq pt_lst (loc:kpblc-conv-2d-to-3d
(vlax-safearray->list
(vlax-variant-value (vla-get-coordinates item))
) ;_ end of vlax-safearray->list
) ;_ end of loc:kpblc-conv-2d-to-3d
vla_3dpoly (vla-add3dpoly
(vla-objectidtoobject adoc (vla-get-ownerid item))
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbdouble
(cons 0 (1- (length pt_lst)))
) ;_ end of vlax-make-safearray
pt_lst
) ;_ end of vlax-safearray-fill
vlax-vbvariant
) ;_ end of vlax-make-variant
) ;_ end of vla-add3dpoly
) ;_ end of setq
(foreach prop '("closed" "layer" "lineweight"
"linetype" "color" "linetypegeneration"
"elevation"
)
(if (and (vlax-property-available-p item prop)
(vlax-property-available-p vla_3dpoly prop t)
) ;_ end of and
(vlax-put-property vla_3dpoly prop (vlax-get-property item prop))
) ;_ end of if
) ;_ end of foreach
(vla-erase item)
) ;_ end of foreach
) ;_ end of if
(vla-endundomark adoc)
(princ)
) ;_ end of defun
Tyke
15th Jun 2006, 12:57 pm
Thanks for that kpblc, it works perfectly. :D
Sorry for being a pest, but does anyone have it in VBA?
:oops:
Tyke
kpblc
15th Jun 2006, 02:40 pm
Sorry I don't like VBA at AutoCAD, so I'm not using it... Why do you have to use VBA? You can run this lisp by
ThisDrawing.SendCommand "lwp-2pl" & vbcrAnd it's enough (I hope so).
Tyke
15th Jun 2006, 03:47 pm
I do most of my programming in full blown Visual Basic (not ACAD VBA) and I am now wanting to move over to ACAD VBA and learn that. I have written a lot of LISP (not Visual Lisp) but that was a long time ago and I don't really want to go back to it.
The VBA code is to teach myself something. I can and will use your VL code, starting Monday. Thanks for your invaluable help.
Tyke
Powered by vBulletin™ Version 4.1.2 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.