Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modify existing LISP

6 REPLIES 6
Reply
Message 1 of 7
tamslaczk
261 Views, 6 Replies

Modify existing LISP

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?

Labels (2)
6 REPLIES 6
Message 2 of 7
Sea-Haven
in reply to: tamslaczk

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)))
Message 3 of 7
paullimapa
in reply to: tamslaczk

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.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 7
komondormrex
in reply to: tamslaczk

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)
)
Message 5 of 7
tamslaczk
in reply to: paullimapa

It's the latter, I have different 2dPolys on multiple layers, so I would
like the original 2DPoly layer for the created 3DPoly.
Message 6 of 7
ronjonp
in reply to: komondormrex

@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)))

 

Message 7 of 7
komondormrex
in reply to: ronjonp

your right

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report