TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: nekonihonjin on August 15, 2022, 10:30:43 PM
-
Hi guys, I found in a forum this code that places points in the intersections between polylines, originally it uses this format to request the entities
(setq snam (car (entsel "\nPick ore area: "))) ;select the bigger polygon
(setq snam2 (car (entsel "\nPick starting level section: "))) ;select smaller
then
(setq sobj (vlax-ename->vla-object snam))
(setq jobj (vlax-ename->vla-object jnam))
(setq intpts (VxGetInters sobj jobj acExtendNone))
(mapcar '(lambda (l) (if (MeIsPointOnObjects l sobj jobj) (vlax-invoke (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)) ) 'AddPoint l ) ) ) intpts );
to perfom the trick...
I want to select a polyline that has just been created with command pline and do it again but it doesn't work
(command "_pline" pivot pt1 "")
(setq jnam2 (car (entlast))); this does not match the format below?
(setq sobj2 (vlax-ename->vla-object snam2));polygon
(setq jobj2 (vlax-ename->vla-object jnam2));pline
it returns this error:
error: bad argument type: consp <Entity name: 232fd765a30>
-
(setq jnam2 (entlast) )
-
Thanks for the reply domenicomaria, is like that.
gotta learn why sometimes (car (entity)) and sometimes not use car
-
gotta learn why sometimes (car (entity)) and sometimes not use car
Click on blue text in code to see a description.
entsel returns the entity name and point used to select the entity. (mouse click)
so useing car on entsel extracts the entity name from the list.
(<Entity name: 3ad7d7e0> (5.58137467447413 1.84391609198915 0.0))
Your code
(setq snam2
(car (<Entity name: 3ad7d7e0
> (5.58137467447413 1.84391609198915 0.0)))) (setq snam2
(<Entity name: 3ad7d7e0
> ))
Just returns the entity name since your not using the mouse to select it. This means its not a list item and when you use car on a non list item it will error
; error : bad argument type <"list"> ; expected <CONS> at [car]
--edit
also you can pass the entity name directly to the vlax-ename->vla-object function like so.
(setq sobj
(vlax
-ename
->vla-object (setq snam2
(car (entsel "\nPick starting level section: "))))) ;if you need to save the entity name use a 2nd setq.
-
excellently explained and fully understood mhupp; thank you very much for your time.