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

tperam
Advocate

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

tperam
Advocate
Advocate

 

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);


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

 

 

0 Likes
Reply
Accepted solutions (1)
482 Views
2 Replies
Replies (2)

BrianEkins
Mentor
Mentor
Accepted solution

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
1 Like

tperam
Advocate
Advocate

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;

 

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

0 Likes