How to get the "X" coordinate of the start of a polyline?

How to get the "X" coordinate of the start of a polyline?

Anonymous
Not applicable
2,245 Views
8 Replies
Message 1 of 9

How to get the "X" coordinate of the start of a polyline?

Anonymous
Not applicable

Please see the attached pic.  If I want to extract the starting x coordinate of a polyline with AutoLISP (which I've highlighted in the Properties window), I would use the vlax-curve-getstartpoint command, yes?  What is the next step in the code to use just the "X" coordinate w/o the "Y" and "Z"?

 

More specifically, I need the polyline in question to go to a specified layer, based on its length.  This length would come from a list of hard-coded values  Here's what I have so far...

 

((and (eq (vla-get-objectname b) "AcDbPolyline") ;; check object is POLYLINE
(setq c (vlax-curve-getstartpoint)) ;; Get start point
(vl-some '(lambda (x)
(equal)
)
'(30 40 50 60
) ;;
) ;; Check whether the x coordinate start point is matched with the list if matches then do this
)
(addprop b "HILMOT-SENSORS")

 

Thanks in advance for any help!

0 Likes
Accepted solutions (1)
2,246 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

(car c)

 

But you're going to need to fix something else:

 

(setq c (vlax-curve-getstartpoint b)) ;; Get start point

 

And I'm not sure about some of the rest -- for example, you have a (lambda) function with (x) as an argument, but no reference to x in the function definition.  And the (equal) function is going to need some arguments to test the equality of.  And I wonder how likely it is that the X coordinate of a location like that in a circular arrangement would ever be exactly any whole-number multiple-of-10 value [as it clearly is not in your image].

Kent Cooper, AIA
0 Likes
Message 3 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... I want to extract the starting x coordinate of a polyline ...  What is the next step in the code to use just the "X" coordinate w/o the "Y" and "Z"?

 

.... I need the polyline in question to go to a specified layer, based on its length.  .....


I'm also having a hard time imagining how the X coordinate of the start point could have anything to do with a Polyline's length.  Can you describe the relationship you want to test for differently, or in more detail?

Kent Cooper, AIA
0 Likes
Message 4 of 9

Anonymous
Not applicable

Hahaha I've got egg on my face now, can't believe I typed that.  I'm trying to assign polylines to layers based on the x value of their starting coordinate, as shown in the properties window.  Length is actually not a factor right now, I might have changed my selection criteria midway through my thought process, thereby tripping over myself.  Derp derp DERP... Smiley Embarassed

0 Likes
Message 5 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....  I'm trying to assign polylines to layers based on the x value of their starting coordinate, as shown in the properties window.  ...:


If that's what you want to check, for whether it's 30 or 40 or 50 or 60, I expect you have Units settings that round things off to whole numbers in the Properties box display.  But in the kind of arrangement in your image, the X coordinate of the endpoint would almost never be exactly a whole number, so you would need to decide how close to one it should be, to qualify in your check.  If the nearest whole-number value is one of those multiples of 10?  If rounded-to-the-closest-multiple-of-2, or of5 is in the list?  That can be built in as a fuzz factor in an (equal) function, but I expect it would require a separate (equal)ity check against each of those values, rather than just something like whether it's a member of a list.  Or the X coordinate could be rounded to whatever precision you want, and the rounded value checked for exact equality to a member of a list.  Is something like that the general direction?

Kent Cooper, AIA
0 Likes
Message 6 of 9

john.uhden
Mentor
Mentor

I don't know much about 10s or 20s or eggs, but whether it's 2D, 3D, or LW,

the first X is easy...

 

(car (vlax-get object 'coordinates))

John F. Uhden

Message 7 of 9

Anonymous
Not applicable

I used round numbers purely as as example.  I will post the entire thing today, once you see it is very straightforward what I'm trying to accomplish.

0 Likes
Message 8 of 9

Anonymous
Not applicable

The program needs to assign differing entities to various layers.  The splines go on the HILMOT-FRAMES LAYER, there is one line that goes on the HILMOT-ROLLERS layer, and then there are a lot of polylines.  I am trying to assign them to layers based on their "Vertex X" parameter that's seen in the Properties palette.  

 

I have the splines and line taken care of, now I need to deal with the polylines.  I've attached the LISP file as it exists so far, and a test block.

0 Likes
Message 9 of 9

Anonymous
Not applicable
Accepted solution

Thanks again to those who answered my posts.  I did get a solution elsewhere that was similar to what you kind folks posted here.

0 Likes