Hey guys!
I have the attached lisp routine, which creates 3dPoly from a 2dPoly and points with 3D coordinates. Pretty useful stuff to batch repair my drawing, but it has one problem, the created 3D poly's layer changes, but I would like to keep the original 2D poly layer.
Can anybody help me?
Fairly simple answer your home work if you look into DXF code 8 which is layer you can get the layer of the ss objects, so your entmake need a (cons 8 layername), hint (cdr (assoc 8 enx)). There is plenty of examples for entmake. This is the tool I use to see the dxf codes.
(entget (car (entsel "\nPick object ")))
when I just type it on command line
(entget (car (entsel)))
If the POINTS & 2DPOLY selected are both on the same layer then @Sea-Haven already provided you with the answer. But if the POINTS & 2DPOLY selected are on different layers and you specifically would like the new 3DPOLY created to have the same layer as the 2DPOLY then that would require a bit more code. Respond if latter is the case.
hey there,
check the mod following
(defun c:polypoly ( / enx idx lst pll ptl sel )
(princ "\nSelect points & 2d polylines: ")
(if (setq sel (ssget '((0 . "LWPOLYLINE,POINT"))))
(progn
(repeat (setq idx (sslength sel))
(setq enx (entget (ssname sel (setq idx (1- idx)))))
(if (= "POINT" (cdr (assoc 0 enx)))
(setq ptl (cons (cdr (assoc 10 enx)) ptl))
(setq pll (cons (cons (cdr (assoc 8 enx)) (cons (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) enx)) pll)) pll))
)
)
(foreach grp pll
(foreach vtx (cadr grp)
(if (setq vtx (car (vl-member-if '(lambda ( a ) (equal vtx (list (car a) (cadr a)) 1e-4)) ptl)))
(setq lst (cons vtx lst))
)
)
(if (cdr lst)
(progn
(entmake (list '(0 . "POLYLINE") (cons 8 (car grp)) '(70 . 8)))
(foreach vtx lst
(entmake
(list
'(00 . "VERTEX")
'(70 . 32)
(cons 10 vtx)
)
)
)
(entmake '((0 . "SEQEND")))
)
)
(setq lst nil)
)
)
)
(princ)
)
@komondormrex FWIW, no need to strip out the code 8 then add it later .. just use (assoc 8 enx) when grabbing the data.
(setq pll (cons (cons (assoc 8 enx) (cons (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) enx)) pll)) pll))
(entmake (list '(0 . "POLYLINE") (car grp) '(70 . 8)))
Can't find what you're looking for? Ask the community or share your knowledge.