.NET

Reply
Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 1 of 7 (203 Views)

block on curve

203 Views, 6 Replies
07-17-2013 10:41 PM

Hi,

I am trying to move a block on a curve with reference to 2 points on the curve.I am facing problem when one point is on horizontal part of curve and other point is at an angle.How do i place the block at angle.Please help.

 

Thanks in advance

Distinguished Mentor
gasty1001
Posts: 582
Registered: ‎04-11-2010
Message 2 of 7 (172 Views)

Re: block on curve

07-18-2013 02:19 PM in reply to: gulzar25

Hi,

 

You can obtain the angle from the first derivative of the curve at that point, and calculate the rotation angle from that angle.

 

Gaston Nunez

Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 3 of 7 (167 Views)

Re: block on curve

07-18-2013 07:37 PM in reply to: gasty1001
Hi,
Thanks for the reply. Can you please help me with sample code.

Thanks
Gulzar
Distinguished Mentor
gasty1001
Posts: 582
Registered: ‎04-11-2010
Message 4 of 7 (158 Views)

Re: block on curve

07-19-2013 06:04 AM in reply to: gulzar25

Hi,

 

The first derivative of a curve is the slope or tangent in a point of a curve, the function/method GetFirstDerivative returns a vector3D with Dx,Dy,Dz components , if your curve is planar, there is no need for Dz, so the tangent=Dy/Dx then theta=math.atan2(Dy,Dx), another method is to calculate the angle from X axis to the derivative vector. GetFirstDerivative should be a method for every object that inherits from the curve class. Try the docs on this topic.

 

Gaston Nunez

Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 5 of 7 (114 Views)

Re: block on curve

08-01-2013 03:49 AM in reply to: gasty1001

Hi,

I tried using the GetFirstDerivative method but i couldnt get direction.Can you please help me with sample code.

 

Thanks

*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 6 of 7 (103 Views)

Re: block on curve

08-01-2013 06:28 AM in reply to: gulzar25

When you said "move block along...", did you mean you want user to drag a selected block/entity and when the mouse cursor is dragged, the block/entity moves along a given curve?

 

If so, one of my articles may be of help:

 

http://drive-cad-with-code.blogspot.ca/2012/03/moving-entity-along-curve.html

 

 

Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 7 of 7 (90 Views)

Re: block on curve

08-01-2013 10:00 PM in reply to: norman.yuan

Hi Norman,

Thanks for the reply.Yes im moving block along a curve but im moving it with respect to 2 points.Im finding it difficult to get the direction.How do i get in which direction should i move.Any ideas??

 

Thanks

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.