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: 

Nurbs in inventor (programe interface/api)

6 REPLIES 6
Reply
Message 1 of 7
mech_tei_gr
1312 Views, 6 Replies

Nurbs in inventor (programe interface/api)

Hi! 

 

  I want informations about how to use nurbs in programme interface and about api for this use in inventor 2014.

 they tell me to wright this issue here...

thank you!

6 REPLIES 6
Message 2 of 7

You can create BSpline curves and surfaces using TransientGeometry.CreateBSplineCurve and TransientGeometry.CreateBSplineSurface methods. Not sure exactly what kind of workflow you are after, you would need to provide some more details about what you are trying to achive.

 

Here is a VBA sample that illustrates some of the work that can be done:

 

Public Sub SplineByNURBS()

    ' Create a new part document.
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
    ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
    
    ' Set a reference to the part component definition.
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition
    
    ' Set a reference to the transient geometry collection.
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
    
    '*** This next section of code creates a sketch that contains
    '*** a single spline that is created using a NURBS definition.
    
    ' Create an array that contains the position of the poles
    ' of the spline. Since we're creating a sketch spline the
    ' coordinates are 2d and are in sketch space.
    Dim adPoles(9) As Double
    adPoles(0) = 0: adPoles(1) = 0
    adPoles(2) = 1: adPoles(3) = 2
    adPoles(4) = 2: adPoles(5) = -2
    adPoles(6) = 3: adPoles(7) = 3
    adPoles(8) = 4: adPoles(9) = 0
    
    ' Create an array that contains the knot information for the spline.
    Dim adKnots(8) As Double
    adKnots(0) = 0
    adKnots(1) = 0
    adKnots(2) = 0
    adKnots(3) = 0
    adKnots(4) = 0.5
    adKnots(5) = 1
    adKnots(6) = 1
    adKnots(7) = 1
    adKnots(8) = 1
    
    ' Define the array for the weights. Since the curve we're creating is
    ' not rational we don't need to provide any weight information.
    Dim adWeights() As Double
    
    ' 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)
    
    ' Create a sketch on the YZ plane.
    Dim oSketch1 As PlanarSketch
    Set oSketch1 = oCompDef.Sketches.Add(oCompDef.WorkPlanes.item(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 oSketch1.SketchFixedSplines.Add(oSpline2D)
    
    '*** This next section of code creates a sketch that contains a single
    '*** spline that is created by fitting through a set of coordinates.
    
    ' Create a BSplineCurve2dDefinition object. This object collects the
    ' fit points, the fit method, and optionally weight and tangent information
    ' (which is not used in this sample).
    Dim oFittedSplineDef As BSplineCurve2dDefinition
    Set oFittedSplineDef = oTransGeom.CreateBSplineCurve2dDefinition
    
    ' Define the fit point coordinates.
    Call oFittedSplineDef.AddPoint(oTransGeom.CreatePoint2d(0, 0))
    Call oFittedSplineDef.AddPoint(oTransGeom.CreatePoint2d(1, -0.25))
    Call oFittedSplineDef.AddPoint(oTransGeom.CreatePoint2d(2, 0.5))
    Call oFittedSplineDef.AddPoint(oTransGeom.CreatePoint2d(3, -0.5))
    Call oFittedSplineDef.AddPoint(oTransGeom.CreatePoint2d(4, 0))
    
    ' Define the fit method.
    oFittedSplineDef.FitMethod = kSweetSplineFit
    
    ' Create the fitted spline. As before, this just creates a transient
    ' b-spline and does not have any associated graphics.
    Set oSpline2D = oTransGeom.CreateFittedBSplineCurve2d(oFittedSplineDef)
    
    ' Create an offset work plane and a new sketch.
    Dim oWP As workplane
    Set oWP = oCompDef.WorkPlanes.AddByPlaneAndOffset(oCompDef.WorkPlanes.item(1), 7)
    Dim oSketch2 As PlanarSketch
    Set oSketch2 = oCompDef.Sketches.Add(oWP)
    
    ' Create a fixed sketch spline using the transient BSplineCurve2d object we
    ' just created. This creates an actual sketch curve that has visible graphics.
    Call oSketch2.SketchFixedSplines.Add(oSpline2D)
    
    ' Create profiles from each of the sketch splines.
    Dim oProfile1 As profile
    Dim oProfile2 As profile
    Set oProfile1 = oSketch1.Profiles.AddForSurface
    Set oProfile2 = oSketch2.Profiles.AddForSurface
    
    ' Add the profiles to an object collection to be able to use them
    ' later as sections for the loft feature.
    Dim oSections As ObjectCollection
    Set oSections = ThisApplication.TransientObjects.CreateObjectCollection
    oSections.Add oProfile1
    oSections.Add oProfile2
    
    ' Create a loft feature. This creates a work surface.
    Dim oLoft As LoftFeature
    'Set oLoft = oCompDef.Features.LoftFeatures.Add(oSections, kSurfaceOperation)
    
    Dim oLD As LoftDefinition
    Set oLD = oCompDef.features.LoftFeatures.CreateLoftDefinition(oSections, kSurfaceOperation)
    Set oLoft = oCompDef.features.LoftFeatures.Add(oLD)
    
    ' Get the work surface and turn off its visibility.
    Dim oWorkSurface As worksurface
    Set oWorkSurface = oLoft.faces.item(1).SurfaceBody.Parent
    oWorkSurface.Visible = False
    
    ' Create an object collection to use as input for the thicken feature to
    ' define the face we want to thicken.
    Dim oFaces As ObjectCollection
    Set oFaces = ThisApplication.TransientObjects.CreateObjectCollection
    oFaces.Add oLoft.faces.item(1)
    
    ' Create the offset feature.
    Dim oThicken As ThickenFeature
    Set oThicken = oCompDef.features.ThickenFeatures.Add(oFaces, 0.2, kPositiveExtentDirection, kSurfaceOperation)

End Sub

 Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

Philippe thank you vey much. Your answer was very detailed.This is about surface. I would like to know informations generally about how inventor use objects in programme interface for edges,splines,cycles etc and how workable is this with nurbs method? thank you for your interesting!

Message 4 of 7

Sorry that question seems too general and vague to address it in a focused reply... If you have no knownledge about how the Inventor API works, you may want to take a look at our beginer resources and knowledge base:

 

http://www.autodesk.com/developinventor

 

http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=17324828

 

https://github.com/ADN-DevTech/Inventor-Training-Material

 

Module 4 of the API Training Material should give you some pointers about how to deal with BRep entities you mentioned.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 7

Philippe thank you for your answer. Sorry for disunderstanding questions but i'm a student so im new in inventor's world.I would like to know which objects use NURBS method with api.  For example i know that CurveEvaluator and SurfaceEvaluator are using NURBS method. Could you tell me more for these objects and please give me a direction about other objects that using NURBS method in Inventor? Only for api. I would be greatful!

Message 6 of 7

What do you mean by telling you more about these objects? Please read the API Help Files, you will find multiple examples illustrating the use of those objects. Their exposed methods and properties are documented in details. Also the resources I pointed out previously contain extensive samples in various programming languages.

 

To get an idea about the various objects in the API that use NURBs, simply make a search on the keyword using the help files:

 

help.png

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 7 of 7

Thank you Philippe i find your answer much helpful!!! Im searching it right now! With my question i mean other objects like  (CurveEvaluator and SurfaceEvaluator) that use Nurbs methods..

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

Post to forums  

Autodesk Design & Make Report