ObjectARX

Reply
Distinguished Contributor
421232206
Posts: 164
Registered: ‎10-21-2010
Message 1 of 5 (97 Views)

how to insert a point on a spline

97 Views, 4 Replies
09-04-2012 02:44 AM

I can't find any good method to insert a point on a spline, please see the code below.  I want to insert a point on an existing spline, and after insertion ,the shape of the spline shoud not change much. 

 

AcDbObjectId idSpline;
        if (!Acad_Selection::smileyfrustrated:elEnt(idSpline,_T("spline")))
        {
            return;
        }
        AcDbSplinePointer pSpline(idSpline,AcDb::kForWrite);
        if (Acad::eOk != pSpline.openStatus()) return;

        ads_point pt;
        if (acedGetPoint(NULL,_T("\nclick:"),pt) != RTNORM)
        {
            return;
        }

        AcGePoint3d pt3d;
        pSpline->getClosestPointTo(asPnt3d(pt),pt3d);
        double dParam = -1;
        pSpline->getParamAtPoint(pt3d,dParam);// here , the value of dParam is not what I want.
        
        acutPrintf(_T("\n%g,round:%d,floor:%d,ceil:%d"),dParam,int(dParam+0.5),floor(dParam),ceil(dParam));


        pSpline->insertFitPointAt(floor(dParam),pt3d);

Technology change world! Coding change technology! We coders are coding!
Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 2 of 5 (94 Views)

Re: how to insert a point on a spline

09-04-2012 05:28 AM in reply to: 421232206

What is your overall goal, and what exactly is the problem with the code you posted?

--
Owen Wengerd
ManuSoft
Distinguished Contributor
421232206
Posts: 164
Registered: ‎10-21-2010
Message 3 of 5 (87 Views)

Re: how to insert a point on a spline

09-04-2012 07:59 AM in reply to: 421232206

my purpose is to insert a fit point to the spline. I get get closest point P1 on the spline for the point I click on the screen.

but  through the method getParamatPoint, the param I got of P1 has nothing to do with the fit point. I want to use insertFitPointAt. and insertFitPointAt requires the number of fit point.  is there an existing method that can return which two fit points P1 is between.

    

Technology change world! Coding change technology! We coders are coding!
Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 4 of 5 (82 Views)

Re: how to insert a point on a spline

09-04-2012 11:03 AM in reply to: 421232206

There is no existing method to do that directly. You did not describe your overall goal, so I can't offer any alternative solutions.

--
Owen Wengerd
ManuSoft
Distinguished Contributor
421232206
Posts: 164
Registered: ‎10-21-2010
Message 5 of 5 (74 Views)

Re: how to insert a point on a spline

09-04-2012 06:10 PM in reply to: 421232206

oh, if so , I have to calculate the "param" for each fit point, then compare these params with the insert point and determine which fit point is the right one for "insertFitPointAt".

still,thanks a lot.

Technology change world! Coding change technology! We coders are coding!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community