Changing Z-values for Mep Wire
Hi,I've created a lisp routine to universally change all Z-values to zero for vertexes of electrical wires.
This has worked beautifully, up until now that is.
In the attached file I get 'exception occured'. Even worse, my routine seems to eliminate vertexes at times
I think this may be caused by the extreme values och X and Y coord.
Other than that, I'm essentially stuck....
(defun c:ELZ (/ SelectionSet SelectionLength CurrentEntity CurrentObject CoordList CoordLength)(princ "\nElevation Zero") (vl-load-com)(setq OldOsMode (getvar "OSMODE"))(setvar "OSMODE" 0)(setq SelectionSet (ssget "x" '((0 . "AECB_WIRE"))))(setq SelectionLength (sslength SelectionSet))(princ SelectionLength)(setq i 0)(repeat SelectionLength(setq CurrentEntity (ssname SelectionSet i) i (1+ i))(setq CurrentObject (vlax-ename->vla-object CurrentEntity))(setq CurrentLocation (vlax-get CurrentObject 'Location))(setq CurrentLocation (subst 0.0 (nth 2 CurrentLocation) CurrentLocation))(vlax-put CurrentObject 'Location CurrentLocation)(setq CoordList (vlax-get CurrentObject 'Coordinates)) (setq CoordLength (/ (length CoordList) 3))(setq CurrentNormal (list 0.0 0.0 1.0))(vlax-put CurrentObject 'Normal CurrentNormal)(setq j 2)(repeat CoordLength (setq CoordList (LM:SubstNth 0.0 j CoordList)) (vlax-put CurrentObject 'Coordinates CoordList) (setq j (+ 3 j))))(princ)(setvar "OSMODE" OldOsMode))(defun LM:SubstNth ( a n l / i ) (setq i -1) (mapcar '(lambda ( x ) (if (= (setq i (1+ i)) n) a x)) l))
test.dwg Ok, so I've continued troubleshooting the file above and it seems that it has to do with the mep object having vertex duplicates
The issue alltogether arises from the line
(vlax-put CurrentObject 'Coordinates Coordlist)
I've also tried
(vla-put-coordinates CurrentObject Coordlist)
After converting the coordlist to a safearray variant
It seems alltogether that the Coordinates for the object is somewhat corrupted, as I'm not allowed to edit the list or variant
Any tips?
P.s. you probably need mep object enabler to see anything in the attached dwg
页:
[1]