Author Topic: Entlast not working  (Read 813 times)

0 Members and 1 Guest are viewing this topic.

nekonihonjin

  • Newt
  • Posts: 103
Entlast not working
« 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
Code: [Select]
(setq snam (car (entsel "\nPick ore area: "))) ;select the bigger polygon
(setq snam2 (car (entsel "\nPick starting level section: "))) ;select smaller
then
Code: [Select]
(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

Code: [Select]
(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>


« Last Edit: August 15, 2022, 10:59:32 PM by nekonihonjin »

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: Entlast not working
« Reply #1 on: August 16, 2022, 01:22:00 AM »
(setq jnam2 (entlast) )

nekonihonjin

  • Newt
  • Posts: 103
Re: Entlast not working
« Reply #2 on: August 16, 2022, 10:58:02 AM »
Thanks for the reply domenicomaria, is like that.

gotta learn why sometimes (car (entity)) and sometimes not use car

mhupp

  • Bull Frog
  • Posts: 250
Re: Entlast not working
« Reply #3 on: August 16, 2022, 11:51:23 PM »
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
Code - Auto/Visual Lisp: [Select]
  1. (setq snam2 (car (entsel "\nPick starting level section: ")))
  2. (setq snam2 (car (<Entity name: 3ad7d7e0> (5.58137467447413 1.84391609198915 0.0))))
  3. (setq snam2 (<Entity name: 3ad7d7e0> ))

Code - Auto/Visual Lisp: [Select]
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.

Code - Auto/Visual Lisp: [Select]
  1. (setq sobj (vlax-ename->vla-object (car (entsel "\nPick starting level section: "))))
  2. (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.
  3.  
  4. (setq sobj2 (vlax-ename->vla-object (entlast)));polygon
« Last Edit: August 17, 2022, 01:35:20 PM by mhupp »

nekonihonjin

  • Newt
  • Posts: 103
Re: Entlast not working
« Reply #4 on: August 17, 2022, 10:51:11 AM »
excellently explained and fully understood mhupp; thank you very much for your time.