Create Points on a Polyline a certain distance and reset command at new vertex

Create Points on a Polyline a certain distance and reset command at new vertex

abernalUMGGH
Participant Participant
9,130 Views
18 Replies
Message 1 of 19

Create Points on a Polyline a certain distance and reset command at new vertex

abernalUMGGH
Participant
Participant

I am searching for a way to create cogo points on a polyine a certain distance interval and then reset the command once a new vertex is hit. Before I have used the CREATEPOINTMEASUREOBJECT command, however this command neglects vertices on a polyline and continues it's operation on this polyline. Therefore, I have to explode the polyine and perform this command on every segment of the exploded polyline. 

 

Performing a command that creates cogo points in this fashion would greatly automate this process/reduce time and not make this a tedious task that takes days for specific projects. I have already done a decent amount of research on this and found no similar problems. I have come to the conclusion that perhaps a lisp routine may need to be created for this problem.

 

Any thoughts or suggestions?

Accepted solutions (1)
9,131 Views
18 Replies
Replies (18)
Message 2 of 19

essam-salah
Collaborator
Collaborator

hi @abernalUMGGH ;

. I have come to the conclusion that perhaps a lisp routine may need to be created for this problem.

 


of course . and that would be a simple one.

0 Likes
Message 3 of 19

abernalUMGGH
Participant
Participant

Hi @essam-salah,

 

Any good resources for this specific problem set that I can look into? Care to elaborate?

 

Thank you,

 

 

0 Likes
Message 4 of 19

essam-salah
Collaborator
Collaborator

hi@abernalUMGGH ;

yes, send me a detailed example so ill see if i can help.

0 Likes
Message 5 of 19

tcorey
Mentor
Mentor

Do you need the offset part of the function, or just the Measure part?



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 6 of 19

abernalUMGGH
Participant
Participant

@essam-salah,

 

Attached is an example DWG with a Polyline that has been exploded and cogo points already layed out in the correct fashion.

 

To reiterate, I would like to find a way to perform this task without exploding the polyline and using the CREATEPOINTMEASUREOBJECT command as currently done. Note that this is an example, and real world tasks could have more that 20 line segments. If you use the above command without exploding the plyline, then the cogo points are laid out in a fashion that ignores the vertices and just relies on polyline stations. I would like to reset the command after every polyline segment or vertice.

 

Thank you!

 

Here is a screnshot as well: 

Polyline with cogo points using CREATEPOINTMEASURE OBJECT command.Polyline with cogo points using CREATEPOINTMEASURE OBJECT command.

0 Likes
Message 7 of 19

abernalUMGGH
Participant
Participant

Here is the attached file.

0 Likes
Message 8 of 19

tcorey
Mentor
Mentor

I will try to take a look this evening when I have a modern version of Civil 3D available. 

 

You didn't say if you will need offsets.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 9 of 19

abernalUMGGH
Participant
Participant

Hi @tcorey,

 

Thank you for the help. Offsetting is not really an issue. I just did that in the CREATEPOINTMEASUREOBJECT command so that the points and polyline can be visually seen. The CREATEPOINTMEASUREOBJECT command gives the ability to offset from the polyline, although you can alternatively just do that from offsetting the polyline before you that command too. 

 

Best,

0 Likes
Message 10 of 19

tcorey
Mentor
Mentor

Try this:

 

(defun c:go ( / pl coords len ctr incr incra p1 p2 p3  dist)
  (vl-load-com)
  (setq pl (vlax-ename->vla-object (car (entsel "\nSelect Polyline: "))))
  (setq coords (vlax-get pl 'Coordinates)
	len (length coords)
	ctr 0
	incr (getreal "\nEnter Increment: ")
        incrA 0.0)

  (while (< ctr len)
    (setq incra 0)
    (setq p1 (list (nth ctr coords) (nth (1+ ctr) coords))
	  p2 (list (nth (+ ctr 2) coords) (nth (+ ctr 3) coords))
	  p3 (polar p1 (angle p1 p2) (+ incr incrA))
	  )
    	(setq dist (distance p1 p2))
        (while (<= (distance p1 p3) dist)
	   
		(vl-cmdf "Point" p3)
		(setq p3 (polar p1 (angle p1 p2) incra))
                (setq incra (+ incr incra))
	  )
    
        
    (setq ctr (+ ctr 2))
  );end while
  );end defun


Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 11 of 19

tcorey
Mentor
Mentor

The routine creates AutoCAD Point objects. To see them, but sure to set PDMODE to 2.

 

Use _AeccCreatePtConvertAdeskPts command to convert to Civil 3D COGO Points.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 12 of 19

abernalUMGGH
Participant
Participant

Hi @tcorey,

 

The Lisp Routine is giving me the following error:

 

; error: bad argument type: 2D/3D point: (nil nil)

0 Likes
Message 13 of 19

essam-salah
Collaborator
Collaborator

I've tried the lisp and it works exactly as expected except for the case of single line polyline. 

0 Likes
Message 14 of 19

abernalUMGGH
Participant
Participant

Hi @essam-salah  and @tcorey

 

Your help is much appreciated.

 

Yes the routine seems to be running but I am still getting the same error message. 

 

I believe that the routine does not have an equal interval on the increment prompt. For example, I would like to have an interval of 20' on each segment of the polyline, but resets if the layed out points reaches a new vertex of the polyline. 

 

The screenshot below is what the routine looks like with an input of 20' increment. Note that the points are not on equal intervals. The polyline to the left is an example where I used the CREATEPOINTMEASUREOBJECT command, but had to explode the polyline entirely.

 

Output Example with Increment of 20''Output Example with Increment of 20''

Error message shown.Error message shown.

0 Likes
Message 15 of 19

tcorey
Mentor
Mentor

I'm not sure why it's giving the error. If I get time to get back to it, I will take another look.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 16 of 19

Jeff_M
Consultant
Consultant
Accepted solution

Here's my offering. You can select more than one polyline, enter the increment to use, then C3D points will be created along the polylines, at the specified increment, and the increment restarts at each vertex.

 

(defun c:measurefromplinevertices (/ BASE C3D C3DDOC ENAME I INCREMENT J PL POINTS SS)
  (vl-load-com)
    (defun getC3D	()
    (vl-load-com)
    (setq C3D (strcat "HKEY_LOCAL_MACHINE\\"
		      (if vlax-user-product-key
			(vlax-user-product-key)
			(vlax-product-key)
		      )
	      )
	  C3D (vl-registry-read C3D "Release")
	  C3D (substr
		C3D
		1
		(vl-string-search
		  "."
		  C3D
		  (+ (vl-string-search "." C3D) 1)
		)
	      )
	  C3D (vla-getinterfaceobject
		(vlax-get-acad-object)
		(strcat "AeccXUiLand.AeccApplication." C3D)
	      )
    )
    (setq C3Ddoc (vla-get-activedocument C3D))
  )
  (princ "\nSelect polylines to set points on by measuring: ")
  (if (setq ss (ssget '((0 . "*POLYLINE*"))))
    (progn
      (initget 7)
      (setq increment (getreal "\nIncrement for points to be set: "))
      (setq i -1)
      (getC3D)
      (setq points (vlax-get C3Ddoc 'points))
      (while (setq ename (ssname ss (setq i (1+ i))))
	(setq pl (vlax-ename->vla-object ename))
	(setq j 0
	      base 0)
	(while (< j (vlax-curve-getendparam pl))
	  (vlax-invoke points 'add (vlax-curve-getpointatparam pl j))
	  (while (< (setq base (+ base increment)) (vlax-curve-getdistatparam pl (+ 1 j)))
	    (vlax-invoke points 'add (vlax-curve-getpointatdist pl base))
	    )
	  (setq j (1+ j)
		base (vlax-curve-getdistatparam pl j)
		)
	  )
	(vlax-invoke points 'add (vlax-curve-getpointatparam pl j))
	)
      )
    )
  (princ)
  )
Jeff_M, also a frequent Swamper
EESignature
Message 17 of 19

abernalUMGGH
Participant
Participant

Hi @Jeff_M

 

This works great. thank you! Also, @tcorey  and @essam-salah the help is much appreciated.

 

Best Regards,

0 Likes
Message 18 of 19

tcorey
Mentor
Mentor

I have learned another technique from you @Jeff_M . I didn't know about those param functions. I had to read up on them, but now I can follow your program and understand it. Thanks!



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 19 of 19

Anonymous
Not applicable

Thanks Jeff

 

That routine works great, is there a way to do exactly the same but not add the points to the vertices but get them extracted and an interval from the beginning of the polyline to the end? Basically interpolate 3d points along the poly at a given interval.

 

Kind regards

 

Regis

0 Likes