Lisp Comman to create Points

Lisp Comman to create Points

rogersmi87
Contributor Contributor
5,259 Views
5 Replies
Message 1 of 6

Lisp Comman to create Points

rogersmi87
Contributor
Contributor

Is there a comman to create points on the corners of a polyline?

 

For instance, at each corner of a recatangular pond?

 

If not, is there a command to place a point in the center of specific shapes? 

 

I have googled all this, and can't find what I am looking for.

0 Likes
Accepted solutions (1)
5,260 Views
5 Replies
Replies (5)
Message 2 of 6

devitg
Advisor
Advisor

Please upload a sample dwg , with a before and after. 

0 Likes
Message 3 of 6

ВeekeeCZ
Consultant
Consultant

Try this Lee's complex pt manager...

http://lee-mac.com/ptmanager.html

 

or simple routine

Spoiler
(vl-load-com)

(defun c:foo ( / obj c i x y e)
  (setq *model-space* (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
  (setq obj (vlax-ename->vla-object (car (entsel))))
  (setq c (vlax-get obj "Coordinates")
        i 0
        e (vla-get-elevation obj)
  )
  (repeat (/ (length c) 2)
    (setq x (nth i c)
          y (nth (1+ i) c)
    )
    (vla-addpoint *model-space* (vlax-3d-point (list x y e)))
    (setq i (+ i 2))
  )
  (princ)
)

made by alanjt, modified. Original available here

 

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@rogersmi87 wrote:

Is there a comman to create points on the corners of a polyline?

For instance, at each corner of a recatangular pond?

....


BeekeeCZ's/alanjt's routine apparently does only one LW[only]Polyline at a time.  Here's a [lightly tested but apparently viable] way to do that for as many as you want to select, all at once, and they can be LW, "heavy" 2D or 3D Polylines, or any combination of varieties.  It works in different UCS's.  It puts the Points on the current Layer, but could be made to match the Layer of the Polyline, and there are other possible enhancements, such as to set a PDMODE value for Point visibility.

 

(defun C:PPV (/ ppvss n pl m); = Points at all Polyline Vertices
  (prompt "\nTo place Points at the vertices of all selected Polylines,")
  (if (setq ppvss (ssget '((0 . "*POLYLINE"))))
    (repeat (setq n (sslength ppvss)); then
      (setq pl (ssname ppvss (setq n (1- n))))
      (repeat
        (setq m (+ (fix (vlax-curve-getEndParam pl)) (if (vlax-curve-isClosed pl) 0 1)))
        (command "_.point" "_none" (trans (vlax-curve-getPointAtParam pl (setq m (1- m))) 0 1))
      ); repeat [within each Polyline]
    ); repeat [through selection]
    (prompt "\nNo Polyline(s) selected.")
  ); if
  (princ)
); defun
(vl-load-com)
Kent Cooper, AIA
Message 5 of 6

Kent1Cooper
Consultant
Consultant

@rogersmi87 wrote:

.... is there a command to place a point in the center of specific shapes? 

....


A Search will reveal a variety of threads about finding the centers of things. But you would need to decide what "center" means in some cases.  There's the center of the bounding box, the "center of gravity" [which you can get by calculation for certain kinds of shapes, or from making a Region out of it for any shape and getting its Centroid property], and other possible definitions.  For triangles specifically, there are a batch of ways to define the center, five of which you can identify with my TriangleCenters.lsp routine, available here.  For some regular-enough shapes, several and sometimes all definitions would come up with the same center location, but certainly not for a lot of shapes.

Kent Cooper, AIA
0 Likes
Message 6 of 6

Anonymous
Not applicable

Thank youWoman Happy

 

0 Likes