Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Spline Manipulation

1 REPLY 1
Reply
Message 1 of 2
Anonymous
525 Views, 1 Reply

Spline Manipulation

Hi,

 

I am trying to create competely customized splines via the Inventor API for some while now. I managed to get all the important information about user-drawn splines with the .geometry-property and the according methods of the BSplineCurve2d-Object . I know that the BSplineCurve2d-Object as a transient geometry is a mere mathematical representation without graphical counterpart.

 

Nevertheless:

 

Is there a way to manipulate e.g. the weights of control- and fitpoints of a spline? Or the order?

 

FixedSplines for example use the BSplineCurve2d-Object when added to a Sketch (see also Spline - create NURBS API Sample).

Now, I use BSplineCurve.PutBSplineInfoAndData( Order As Long, Poles() As Double, Knots() As Double, Weights() As Double, IsPeriodic As Boolean ) and alter the weights-array to be empty. Then I use this BSplineCurve to draw a FixedSpline the weights are ignored completely.

 

Help is appreciated, thanks in advance

 

ps: The method

BSplineCurve.GetBSplineInfo Method BSplineCurve.GetBSplineInfo( Order As Long, NumPoles As Long, NumKnots As Long, IsRational As Boolean, IsPeriodic As Boolean, IsClosed As Boolean, IsPlanar As Boolean, PlaneVector() As Double )

enables the user to examine wether the spline is rational or not. But when used, none of the splines drawn in a sketch is rational (IsRational is always False). The Spline - create NURBS API Sample states that it is creating a NURB, but ist is not. As long as one cannot change the IsRational-property, the name and description of this sample is not true.

 

 

1 REPLY 1
Message 2 of 2
F.Porcher
in reply to: Anonymous

Hello Benjamin,

 

I had a similar problem recently. I believe the solution requires the combinations of two concepts. Firstly, you need to create the spline's mathematical representation, i.e. the transient geometry object, using the CreateBSplineCurve2d function, which allows you to choose the spline order, poles, knots and weights. Secondly, you need to split this spline in two using first the Evaluator.GerParamExtents function, then finally creating two new BSplineCurve2d, with the goal of combining both in a Sketch with the SketchFixedSpline function.

 

I believe I can make myself clearer with an example (VCA-Code testet in Autodesk Inventor 2019):

 

Public Sub CreateNURBS(oTransGeom, oSketch, adPoles, gewicht)
    ' Create an array that contains the knot information for the spline.
    ' k = 4 -> Fourth order = Third Degree | Four nodes
    Dim adKnots(7) As Double
    adKnots(0) = 0
    adKnots(1) = 0
    adKnots(2) = 0
    adKnots(3) = 0
    adKnots(4) = 1
    adKnots(5) = 1
    adKnots(6) = 1
    adKnots(7) = 1

    ' Define the array for the weights.
    Dim adWeights(3) As Double
    adWeights(0) = 1
    adWeights(1) = gewicht(0)
    adWeights(2) = gewicht(1)
    adWeights(3) = 1

    ' Create a spline that is order 4 and non-periodic. This just creates the
    ' curve as a transient geometry object, so there are still not any graphics
    ' within Inventor that represent this curve.
    Dim oSpline2D As BSplineCurve2d
    Set oSpline2D = oTransGeom.CreateBSplineCurve2d(4, adPoles, adKnots, adWeights, False)

' Get start and end spline position Dim startParam As Double Dim endParam As Double Call oSpline2D.Evaluator.GetParamExtents(startParam, endParam) ' Extract two curves where each is the ' half of the original ' relative to the curves parameter space. Dim curves(1) As BSplineCurve2d Set curves(0) = oSpline2D.ExtractPartial _ (startParam, endParam / 2) Set curves(1) = oSpline2D.ExtractPartial _ (endParam / 2, 1) ' Create a fixed sketch spline using the transient BSplineCurve2d object we ' just created. This creates an actual sketch curve that has visible graphics. Call oSketch.SketchFixedSplines.Add(oSpline2D) End Sub

For more information please see the post from philippe.leefsma  here.

 

This method has the disadvantage of not connecting the curve with other geometry objects, meaning this sketch is not ready for extrusion, revolution, etc. If this is a problem for you, please comment below, since I already found another the solution.

 

Regards,
F. Porcher

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report