Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using C++ how do I convert a spline into a NurbsCurve3D to make Intersection work

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
tperam
290 Views, 2 Replies

Using C++ how do I convert a spline into a NurbsCurve3D to make Intersection work

 

Using C++, how do I convert a spline into a NurbsCurve3D as the following Intersection with a spline does not work?

 

I believe a spline needs to be converted to a NurbsCurve3D type for Intersection to work. Am I right?

 

IntersectionPtsObjCollspline = Planenormal->intersectWithCurve(spline);

 

Part of my code is given below.

 

Thurai


//////////////////////////////////////////////////
// Create an object collection for the points.
Ptr<ObjectCollection> points = ObjectCollection::create();
if (!points)
return false;

// Define the points the spline with fit through.
points->add(Point3D::create(- 5, -6, -2));
points->add(Point3D::create(0, 0, 0));
points->add(Point3D::create(6, 4, 4));

// Create the spline.
Ptr<SketchCurves> sketchCurves = sketch->sketchCurves();
if(!sketchCurves)
return false;

Ptr<SketchFittedSplines> splines = sketchCurves->sketchFittedSplines();
if (!splines)
return false;

Ptr<SketchFittedSpline> spline = splines->add(points);
if (!spline)
return false;

 

double h, x, y, z, Pi, Angle;

/* Compute VTOLBody.zValueOfPlaneBulk[Ifr][IzBulk] */
z = 0.0;

h = 2.0;


Ptr<Vector3D> VectorNormal = adsk::core::Vector3D::create(0, 1, 0);

Ptr<Plane> PlaneNormal = adsk::core::Plane::create(adsk::core::Point3D::create(0, 1.0, 0), Vectornormal);
if(!Planenormal)
return false;


Ptr<ObjectCollection> IntersectionPtsObjCollspline = adsk::core::ObjectCollection::create();
if(!IntersectionPtsObjCollspline)
return false;


/* Dummy Initialize */
Ptr<Point3D> splineIntersectPts3D = adsk::core::Point3D::create(0, 0, 0);


IntersectionPtsObjCollspline = Planenormal->intersectWithCurve(spline);
if (!IntersectionPtsObjCollspline) return false;

ui->messageBox(" After intersectWithCurve() ");

splineIntersectPts3D = IntersectionPtsObjCollspline->item(0);


/////////////////////////////////////////////////

 

 

2 REPLIES 2
Message 2 of 3
BrianEkins
in reply to: tperam

The worldGeometry property of the SketchFittedSpline will return a NurbsCurve3D object in component space.  The geometry property will return a NurbsCurve3D object in sketch space. For what you're wanting to do, you'll want to use the worldGeometry property, http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-36b147d8-92af-451b-84db-11f407a23742.  

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3
tperam
in reply to: BrianEkins

Hi Brian,

              it worked Okay.

 

Thanks.

Thurai.

 

the lines of code are as below:

/////////////////////////////////////////////////////

 

//Ptr<NurbsCurve3D> propertyValue = sketchFittedSpline_var->worldGeometry();
Ptr<NurbsCurve3D> splineNurbsCurve3D = spline->worldGeometry();
if(!splineNurbsCurve3D)
return false;

ui->messageBox(" After splineNurbsCurve3D ");

IntersectionPtsObjCollspline = Planenormal->intersectWithCurve(splineNurbsCurve3D);
if (!IntersectionPtsObjCollspline) return false;

 

//////////////////////////////////////////////////////////////////

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report