Create a path array with 2 points of the object on the curve

Create a path array with 2 points of the object on the curve

ColinRuy
Explorer Explorer
945 Views
7 Replies
Message 1 of 8

Create a path array with 2 points of the object on the curve

ColinRuy
Explorer
Explorer

I work in the event industry so I have a lot of fencing to draw and I'm trying to make it as efficient as possible. I currently use a path array to generate my fencing quickly. It works great when its straight lines but as soon as there is a curve, I can't get my blocks to stay linked. (cfr. image )

 

Capture d'écran 2024-11-05 141809.png

 

Is there any solution to force 2 points of the block to stay on the path ? The closest solution I could get is to set the base point on the middle of the block so I can get the tangent but it's not perfect.

 

I hope I'm being clear, English is not my first language.

0 Likes
Accepted solutions (3)
946 Views
7 Replies
Replies (7)
Message 2 of 8

vinodkl
Mentor
Mentor

Hello @ColinRuy 

 

This should be possible using lisp. Please check this thread: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/multiple-constraints-along-array-pat... 

--------------------------------------------------------------------------------------------------------------------------
ವಿನೋದ್ ಕೆ ಎಲ್( System Design Engineer)
Likes is much appreciated if the information I have shared is helpful to you and/or others.

Please mark "Accept as Solution" if my reply resolves the issue or answers your question, to help others in the community.
--------------------------------------------------------------------------------------------------------------------------
0 Likes
Message 3 of 8

Kent1Cooper
Consultant
Consultant

There was also another very similar topic very recently, either here or in the Customization Forum, but I haven't found the right combination of Search terms to locate it....

Kent Cooper, AIA
0 Likes
Message 4 of 8

leeminardi
Mentor
Mentor
Accepted solution

I think the following should do what you want.

 

leeminardi_0-1731432065990.png

(defun C:BlocksOnSpline( / blockname delta d path osm endpar dToEnd n p1 p2)
;  Adds blocks along a spline with the base point and a secnd point of the blocck also on the spline.
; The second point is specified as a distance along the x acis of the block from the base point.
; L. Minardi 11/12/2024  
(command "ucs" "w")
(setvar 'osmode 0)
(setq blockname (getstring "\nEnter block name: "))
(setq delta (getreal
	      "\nEnter distance to second point on x axis of block: "
	    )
)
(setq
  d	 0
  path	 (car (entsel))
  endpar (vlax-curve-getEndParam path)
  osm	 (getvar 'osmode)
)
(setq dToEnd (vlax-curve-getDistAtParam path endpar)
      n	     (atoi (rtos (/ dToEnd delta) 2 2))
)
(setvar "cmdecho" 0)
(setq p1 (vlax-curve-getPointAtParam path 0))
(repeat	n
  (setq d (+ d delta))
  (setq p2 (vlax-curve-getPointAtDist path d))
  (command "-insert" blockname '(0 0 0) 1 1 0)
  (command "_align" "last" "" '(0 0 0) p1 '(1 0 0) p2 "" "n")
  (setq p1 p2)
)					; end repeat
(setvar 'osmode osm)
(setvar "cmdecho" 1)
(princ)
)


 

Do you need another parameter to specify the distance between the blocks?

 

 

lee.minardi
Message 5 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

How about implementing the cord length...

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/dividing-a-curve-equaly/m-p/10279075...

 

 

Edit: Attached a version that creates a segmented curve by segments equally long. Then could be created dynarray (between dist should be a little bit longer, say by .0001)

0 Likes
Message 6 of 8

leeminardi
Mentor
Mentor
Accepted solution

@ВeekeeCZ wrote:

How about implementing the cord length...

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/dividing-a-curve-equaly/m-p/10279075...

 

 

Edit: Attached a version that creates a segmented curve by segments equally long. Then could be created dynarray (between dist should be a little bit longer, say by .0001)


@ВeekeeCZ , It seems like extra work for the user to create the array of blocks in two steps.  I got the following results referencing the segmented curve generated by your code and then used the ARRAY PATH.   

leeminardi_0-1731546366376.png

Here's a second attempt using PSEGLENGTH but with a distance of 1.201 !

leeminardi_1-1731546661669.png

 

 

 

 

lee.minardi
0 Likes
Message 7 of 8

ВeekeeCZ
Consultant
Consultant

Lee, you're not very versed with this command, are you? 

 

I did not try to address this specific case — I just found that the original algorithm of the chord routine did not work very well for me, so I rewrote it to better suit my needs. If the OP finds it useful, it could be easily adjusted to this case. 

0 Likes
Message 8 of 8

ColinRuy
Explorer
Explorer

Hey, 

 

Thanks @leeminardi and @ВeekeeCZ , I use a mix of both your commands and it works great. First I divide the curb with Bee's command, then I use Lee's to put the blocks on the divided spline. Dividing the spline first seems to correct the slight error I had using only Lee's command.

 

Thank to you both !

Cheers.

0 Likes