Jump to content

Get starting point of a polyline


Radu Iordache

Recommended Posts

Hello, can someone help with a simple lisp to get the coordinates of the start point of a lwpolyline in the form Y,X (north,east) and store them in a variable? Thanks a lot!

Link to comment
Share on other sites

Following on from Tharwat suggestion.

 

(setq ent (entsel "\nPick a pline ")) ; pick pline
(setq entg (entget (car ent)))  ; get entity values
(setq pt (cdr (assoc 10 entg))) ; get 1st point

or 

(setq obj (vlax-ename->vla-object (car  (entsel "\nPick a pline ")))) ; pick pline
(setq start (vlax-curve-getstartPoint obj)) ; get 1st point

 

Link to comment
Share on other sites

On 3/11/2023 at 7:13 AM, Tharwat said:

It is not necessarily / required  to convert an entity to vla-object when using it with any of vlax-curve* functions.

Converting to vla-object then using  curve functions is also quite a bit slower.

(setq e (car (entsel)))
(setq o (vlax-ename->vla-object e))
(benchmark '((vlax-curve-getStartPoint e)(vlax-curve-getStartPoint o)))
;;;<Entity name: 1e9f2363150> 
;;;#<VLA-OBJECT IAcadLWPolyline 000001e9df9c2dc8> Benchmarking ..................Elapsed milliseconds / relative speed for 32768 iteration(s):
;;;
;;;    (vlax-curve-getStartPoint E).....1781 / 1.71 <fastest>
;;;    (vlax-curve-getStartPoint O).....3047 / 1.00 <slowest>
;;;
;;;---- Benchmark Utility: In memory of Michael Puckett ----
;;; 
;;;; 3 forms loaded from #<editor "<Untitled-0> loading...">

 

  • Like 1
Link to comment
Share on other sites

Depends on the function of course, if you are processing a lot of lines then program speed can be an issue, only a few lines and the slowest thing is the user and their mouse.

 

I'd go first off with what I know works, and then speed it up if necessary

Link to comment
Share on other sites

11 hours ago, ronjonp said:

Converting to vla-object then using  curve functions is also quite a bit slower.

 

Even tho the documentation says vlax-curve-getstartPoint works with vla-objects  you can feed it entity names as well. i think this works with all vlax-curve functions.

 

-edit

Tharwat-ed

 

(setq SPT (vlax-curve-getstartPoint (car  (entsel "\nPick a pline ")))) ; get 1st point
(vl-cmdf "_.Circle" "_non" SPT "0.25")

 

Edited by mhupp
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...