vlax-put-property and coordinates

vlax-put-property and coordinates

carlos_m_gil_p
Advocate Advocate
1,271 Views
4 Replies
Message 1 of 5

vlax-put-property and coordinates

carlos_m_gil_p
Advocate
Advocate

Hello boys how are you.
I wanted to ask if someone could show me an example of how I can modify the vertices of a 3dpolyline.
But specifically with this function vlax-put-property and coordinates.
I just don't understand how it works with the coordinates property.
Thank you.


AutoCAD 2027.1
Visual Studio Code 1.137.0
AutoCAD AutoLISP Extension 1.6.3
Windows 10 Pro - 22H2 (64 bits)

0 Likes
1,272 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

@carlos_m_gil_p wrote:

.... this function vlax-put-property and coordinates.
I just don't understand how it works with the coordinates property. ....


That property is just a list of XYZ coordinate values, strung into one undifferentiated list.  With a VLA object of a 3DPolyline [here one with three vertices] saved to the 'obj' variable, it looks like this:

 

(vlax-get obj 'Coordinates)
(6612.31 5235.21 0.0 12695.1 10862.8 3.0 7964.04 12288.4 -1.0)

 

In the case of a 3D [or "heavy" 2D] Polyline, there are 3 coordinates for each vertex, so that list represents the following three points:
(6612.31 5235.21 0.0)  (12695.1 10862.8 3.0)  (7964.04 12288.4 -1.0)

 

There are numerous examples of dividing such a list up into the sets of coordinates for each vertex, to save them as point locations.  Then you can manipulate the values in those as points, and when you're done, (append) them all back into one undifferentiated list, and "put" that list into the Coordinates property of the object.

Kent Cooper, AIA
Message 3 of 5

hak_vz
Advisor
Advisor
(setq p1 '(0 0 0) p2 '(5 5 5) p3 '(10 10 0))
(vlax-put eo 'Coordinates (apply 'append (list p1 p2 p3)))

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 4 of 5

carlos_m_gil_p
Advocate
Advocate

Hi guys, thanks for the explanations and examples.
I'll continue studying.


AutoCAD 2027.1
Visual Studio Code 1.137.0
AutoCAD AutoLISP Extension 1.6.3
Windows 10 Pro - 22H2 (64 bits)

Message 5 of 5

john.uhden
Mentor
Mentor

All you need to study is what @hak_vz showed you... (apply 'append ...))

Now to get the coordinates in a meaningful form you can use this function...

   ;; Function to group a flat list of items into a list of
   ;; multiple lists, each of length N, e.g.
   ;; '(A B C D E F G H I) -> '((A B C)(D E F)(G H I))
   (defun @group (lst n / item new)
     (foreach element (reverse lst)
       (setq item (cons element item))
       (if (= (length item) n)
         (setq new (cons item new) item nil)
       )
     )
     new
   )

For heavy and 3D polylines, use an N value of 3.

For lightweights use an N value of 2 (because each vertex has no Z, just X and Y)

John F. Uhden

0 Likes