Author Topic: setq lastpoint  (Read 4958 times)

0 Members and 1 Guest are viewing this topic.

rude dog

  • Guest
setq lastpoint
« on: November 07, 2003, 06:13:51 AM »
question:

If I randomly drew a "line" in 3d space is there any way to extract  the value of the "endpoint" of the line (opposite the startpoint) and setq this point...without having to "manually" repick it agian....

hendie

  • Guest
setq lastpoint
« Reply #1 on: November 07, 2003, 06:37:38 AM »
how about
Code: [Select]
(setq LP (getvar "lastpoint"))

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
setq lastpoint
« Reply #2 on: November 07, 2003, 06:50:19 AM »
Well I like hendie's better but, for the record and since I've already done this!
Code: [Select]
(if (setq e (entlast))
     (setq ent (entget e))
     )
   (if (= (cdr (assoc 0 ent)) "LINE")
     (setq endpt (cdr (assoc 11 ent)))
     ; else
     (prompt "\nLast entity was not a LINE: ")
     )
TheSwamp.org  (serving the CAD community since 2003)

SMadsen

  • Guest
setq lastpoint
« Reply #3 on: November 07, 2003, 06:54:48 AM »
The answer(s) is pretty much dependent on context. As Hendie points out, the LASTPOINT variable is always set after entity creation - and after creating a line it would naturally hold the line's endpoint.
If there's any chanche that the user uses another command before you get to process the line, then LASTPOINT would probably hold a "wrong" point. E.g. a simple ID command will change it.

If that is the case but you're absolutely sure that the line you want is the last created, you can use ENTLAST and extract the endpoint:

Code: [Select]
(if (setq ent (entlast))(cdr (assoc 11 (entget ent))))

If the user gets to draw other entities in between then you will have to have the user pick the line in question and extract the endpoint:

Code: [Select]
(if (setq ent (car (entsel)))(cdr (assoc 11 (entget ent))))

added: didin't see Mark sneak in there :)

Anonymous

  • Guest
setq lastpoint
« Reply #4 on: November 07, 2003, 08:04:41 AM »
that is a tremendous help... you guys (and or gals if applicable) are top notch!
Thanks