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

line start and end points via lisp

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
3396 Views, 13 Replies

line start and end points via lisp

I'm sure this is so basic, but I need to find the start and end points of a
line so that I can manipulate it - I have got the below :

(setq LINE1 (entsel) LNAME (car LINE1))(entget lname)

which returns the following

6.12303e-014 1000.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 500.0 1000.0) (40
. 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))

how do I get hold of the start and end points of the line from this data -
or am I looking for additional info not shown here?

--
Gordon
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: Anonymous

(setq data (entget (car (entsel))))

(setq start (cdr (assoc 10 data)))

(setq end (cdr (assoc 11 data)))


--
Autodesk Discussion Group Facilitator


"Gordon Stephens" wrote in message
news:5683207@discussion.autodesk.com...
I'm sure this is so basic, but I need to find the start and end points of a
line so that I can manipulate it - I have got the below :

(setq LINE1 (entsel) LNAME (car LINE1))(entget lname)

which returns the following

6.12303e-014 1000.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 500.0 1000.0) (40
. 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))

how do I get hold of the start and end points of the line from this data -
or am I looking for additional info not shown here?

--
Gordon
Message 3 of 14
Anonymous
in reply to: Anonymous

Great - thank you Jason - very kind.
--
Gordon


"Jason Piercey" wrote in message
news:5683208@discussion.autodesk.com...
(setq data (entget (car (entsel))))

(setq start (cdr (assoc 10 data)))

(setq end (cdr (assoc 11 data)))


--
Autodesk Discussion Group Facilitator


"Gordon Stephens" wrote in message
news:5683207@discussion.autodesk.com...
I'm sure this is so basic, but I need to find the start and end points of a
line so that I can manipulate it - I have got the below :

(setq LINE1 (entsel) LNAME (car LINE1))(entget lname)

which returns the following

6.12303e-014 1000.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 500.0 1000.0) (40
. 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))

how do I get hold of the start and end points of the line from this data -
or am I looking for additional info not shown here?

--
Gordon
Message 4 of 14
Anonymous
in reply to: Anonymous

You're welcome, Gordon.

--
Autodesk Discussion Group Facilitator


"Gordon Stephens" wrote in message
news:5683226@discussion.autodesk.com...
Great - thank you Jason - very kind.
--
Gordon
Message 5 of 14
faridfarmani2000
in reply to: Anonymous

Hey, Gordon. What if we have a polyline?

Message 6 of 14


@faridfarmani2000 wrote:

Hey, Gordon. What if we have a polyline?


 

May not be watching after all these years, so....

 

If you want to get the start and end points of a Polyline from the entity data list  [if in a 'data' variable as in previous posts], all  vertices are in (assoc 10) entries.  You could do this:

 

  (setq start (cdr (assoc 10 data))); same as for a Line

 

But for the end:


  (setq end (cdr (assoc 10 (reverse data)))); the last such entry

 

BUT if it's a closed  Polyline, that will get the last vertex, not the end  [which is at the same place as the start].

 

The other way, not involving the entity-data list [with LNAME being the entity name as in earlier posts]:


  (setq

    start (vlax-curve-getStartPoint LNAME)

    end (vlax-curve-getEndPoint LNAME)

  )

 

which will  give you the actual end [back at the beginning] for a closed one, rather than the last vertex.  You may need to run:
  (vl-load-com)

to be able to use those functions.

 

Kent Cooper, AIA
Message 7 of 14

Kent1Cooper wrote "May not be watching after all these years, so...."

 

By amazing coincidence after years of not being here, I arrived today and started browsing through recent posts to see one by me which was a surprise - well, well, strange coincidence - thanks for stepping in Kent

 

Message 8 of 14
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote: 

....

The other way...:


  (setq

    start (vlax-curve-getStartPoint LNAME)

     end (vlax-curve-getEndPoint LNAME)

  )

....


 

And by the way, that's a universal  approach, and will get the start and end points from anything that has them -- not just a Line or Polyline, but an Arc, Circle, Ellipse, or Spline, and also the start point [only] of a Ray.

Kent Cooper, AIA
Message 9 of 14
erik.vold
in reply to: Kent1Cooper

What would I do if I wanted to make a lisp that changed the start and end points of a line?

Just an Intern doing his best.
Message 10 of 14
devitg
in reply to: erik.vold

You have to use ENTMOD and UPDATE
Message 11 of 14
Kent1Cooper
in reply to: erik.vold


@erik.vold wrote:

What would I do if I wanted to make a lisp that changed the start and end points of a line?


 

There are several ways.  Do you have the points defined/saved already somehow, or do you need to ask the User for them, or....?  Also, since Message 1 talks  in terms of a Line but the snippet of entity data shown is clearly about a Polyline, which are you actually asking about?  [It would make a big difference to some of the alternative ways.]

Kent Cooper, AIA
Message 12 of 14
erik.vold
in reply to: Kent1Cooper

Maybe I'm understanding wrong but the lisp above tells you the start and end point so then you could use that data in combination with another lisp to move the endpoints.  I have a bunch of parts with bend lines on them and need to offset the ends of the bend lines .01" from the sides of the part.

Here's a link to another post I made about it.

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-help-offsetting-ends-of-lines/t...

 

Just an Intern doing his best.
Message 13 of 14
devitg
in reply to: erik.vold

Would you, please upload a sample.dwg 

It are lines , polyline , bend?? , offset?? , extend??

Message 14 of 14
erik.vold
in reply to: devitg

Sorry the file I was trying to use before wasn't working but this one should. I need the blue LINE .01" away from the sides.

Just an Intern doing his best.

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

Post to forums  

Autodesk Design & Make Report

”Boost