Help to create points list

Help to create points list

carlos_m_gil_p
Advocate Advocate
644 Views
9 Replies
Message 1 of 10

Help to create points list

carlos_m_gil_p
Advocate
Advocate

Hello how are you.


I could help you create a list of points after drawing 3D polyline.
In the DWG file it is what I do.


Excuse my English, but only speak Spanish.

Thank you.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Accepted solutions (1)
645 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

Hi,

 

Try the loop2 see if this is what you want.

 

http://www.afralisp.net/autolisp/tutorials/program-looping.php

 

Leo

0 Likes
Message 3 of 10

Kent1Cooper
Consultant
Consultant

That does not look easy, but I can almost imagine a way to do it.  But first:

 

Am I correct that the vertex locations are to be at the centroids of each perimeter face of the mesh?

 

Would the meshes always be symmetrical like those in your example?  That is, could it draw 3DPolylines along two edges and Mirror them for the other sides, or would need to figure them out for all sides separately?

Kent Cooper, AIA
0 Likes
Message 4 of 10

carlos_m_gil_p
Advocate
Advocate

Hi, thanks for your answers.

 

You need not be the centroid.
It is better to display.

 

The meshes are not symmetrical.
I enclose such as meshes.

 

Thank you and excuse my English.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 5 of 10

Kent1Cooper
Consultant
Consultant

Another question:

 

Your example drawing has four separate 3DPolylines [in different colors] following each edge of the Polygon Mesh.  Do you want them separate like that, or would you rather have one 3DPolyline tracing around all four edges?

Kent Cooper, AIA
0 Likes
Message 6 of 10

carlos_m_gil_p
Advocate
Advocate
Hi How Are you.

I think they should be separate.
To display the colors as was armed.

AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 7 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

@carlos_m_gil_p wrote:
....
I think they should be separate.
....

That's actually a little easier than making one all-the-way-around 3DPolyline, I think.  Try this out:

 

;;  TraceCentroidsAroundMeshEdges.lsp [command name: TCAME]
;;  To Trace along the Centroids [averaged corner locations] of a polygon
;;    Mesh's Edge faces, with a 3DPolyline along each edge, colored separately.
;;  Kent Cooper, 12 October 2015

(defun C:TCAME ; = Trace Centroids Around Mesh Edges
  (/ asso centroid edge mesh edata m n faces)
  (defun asso (code)
    (cdr (assoc code edata))
  ); defun -- asso
  (defun centroid (face / edata c c1 c2 c3 c4)
    (setq
      edata (entget face)
      c 4 ; initial assumption number of corners
      c1 (asso 10) c2 (asso 11) c3 (asso 12) c4 (asso 13); corners
    ); setq
    (if (equal c3 c4 1e-4) (setq c4 '(0 0 0) c 3)); 3-sided
    (mapcar '/ (mapcar '+ c1 c2 c3 c4) (list c c c)); return average of corners
  ); defun -- centroid
  (defun edge (index dir inc color / index clist)
    (repeat dir
      (setq clist (cons (centroid (ssname faces (setq index (+ index inc)))) clist))
    ); repeat
    (command "_.3dpoly")
    (foreach c clist (command "_none" c))
    (command
      "" ; end 3dPoly
      "_.chprop" "_last" "" "_color" color ""
    ); command
  ); defun -- edge
  (if
    (and
      (setq mesh (car (entsel "\nSelect Polygon Mesh: ")))
      (setq edata (entget mesh))
      (= (logand (asso 70) 16) 16); it's a polygon mesh
    ); and
    (progn ; then
      (setq
        m (1- (asso 71)); # of resulting 3dFaces in M direction
        n (1- (asso 72)); in N direction
      ); setq
      (command
        "_.copy" mesh "" '(0 0 0) "@"
        "_.explode" "_last" ; turns into 3dFaces
      ); command
      (setq faces (ssget "_P")); results from Exploding copy of Mesh
      (edge -1 n 1 1); trace centroids on first edge [red]
      (edge -1 m n 2); second edge [yellow]
      (edge (1- (* (1- m) n)) n 1 3); 3rd edge [green]
      (edge (- n) m n 5); fourth edge [blue]
      (command "_.erase" faces ""); [optional]
    ); progn
    (prompt "\nNothing selected, or not a Polygon Mesh."); else
  ); if
  (princ)
); defun

Some things to note:

 

I thought the average of the four corner locations of a 3dFace was the same as its centroid, but they seem to come out in a slightly different location than yours, when used in your first example drawing.  Converting a 3dFace to a Region will give a real centroid, but Regions need to be planar, so the warped faces can't be done that way.  Since Post 4 sounds like it's not critical, I didn't do anything about it, and maybe I should have avoided the word "centroid" in the routine, but I left it in.

 

It does only a single Polygon Mesh object, not the perimeter of the larger multi-mesh collective "objects" in your second sample drawing.  I'm not sure it would be possible [or at least it would be very much more complicated] to draw along the overall-collective edges on those.

 

It could use the usual enhancements -- error handling, command-echo suppression, undo begin/end wrapping, etc., but those can be added easily enough, if it works for you otherwise.

 

If you are Zoomed in far enough that any of the 3DPolylines it draws will not be visible on-screen, the color assignments will not come out right, and one or more of those colors could be imposed on something other than the new 3DPolylines.  It could be made to Zoom out to prevent that problem, if you like.

Kent Cooper, AIA
0 Likes
Message 8 of 10

carlos_m_gil_p
Advocate
Advocate

Hello Brother how are you.

 

It works perfect.
I errore custom control.

 

Thank you.

 

----------------------------------------------------------------------------------------------------------------------------------------

 

I want to ask you another question.

It has nothing to do with this.

 

Some time ago I did a post to apply unfold, about 3d faces.
But I got no answers.
You could help me with that too.
I would send all the material by the proivado.
If you can, of course.

 

Again thank you very much.

 

 


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 9 of 10

Kent1Cooper
Consultant
Consultant

@carlos_m_gil_p wrote:

.... 

It works perfect.
I errore custom control.

 

Thank you.

 

----------------------------------------------------------------------------------------------------------------------------------------

 

I want to ask you another question.

.... a post to apply unfold, about 3d faces.....


You're welcome.  [I'm not sure what you mean by "I errore custom control" -- pardon my lack of Spanish; I speak only English.]

 

On the other question, I looked at your Post history and didn't see something like that, but maybe it was one in Spanish, or could it have been under a different User name?  If you can post a link, I may take another look at it -- I don't remember whether there was some reason I didn't Reply to it, but it may have been only that I didn't have any answer to suggest.  Getting that thread going again will be better than private messages, because if someone comes up with an answer, other people with the same question will be able to find it there.

Kent Cooper, AIA
0 Likes
Message 10 of 10

carlos_m_gil_p
Advocate
Advocate

 

Hello Brother.

 

I meant

 

                "It could use the usual enhancements -- error handling, command-echo suppression, undo begin/end wrapping, etc."

 

With respect to unfold

Sorry, I was not in this forum, was one in Spanish.

And I made a new post.

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3d-faces-down-to-zero-level/td-p/5858...

 

Thank you very much for your help.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes