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: 

WorkPoints AddWorkPointByPlaneAndAxis?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
oransen
423 Views, 3 Replies

WorkPoints AddWorkPointByPlaneAndAxis?

Maybe I'm missing something,but I can't find a function called something like:

 

WorkPoints.AddWorkPointByPlaneAndAxis?

 

Is there one? The point would be created at the intersection of a plane and an axis...

 

 

 

3 REPLIES 3
Message 2 of 4
oransen
in reply to: oransen

I did try it usingWorkPoints.AddByCurveAndEntity but I don't have any sketch lines available, only WorkAxis and WorkPlane. It seems that the first parameter...

 

This object can be an edge or a 2d or 3d sketch entity.

 

...which I don't have.

Message 3 of 4
HermJan.Otterman
in reply to: oransen

Hello Oransen,

 

you where close,

 

look at my code, it will create the workpoint:

 

Private Sub CreatePoint()

Dim oPartDoc As PartDocument = Thisapplication.ActiveDocument

Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition

Dim oAxis As WorkAxis = oCompDef.WorkAxes(5)

Dim oWorkPlane As WorkPlane = oCompDef.WorkPlanes(4)

Dim oWPt As WorkPoint = oCompDef.WorkPoints.AddByCurveAndEntity(oAxis, oWorkPlane)

End Sub

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 4 of 4
oransen
in reply to: HermJan.Otterman

Thanks for your reply HermJan, I had to do it in C++ and got an solution close to yours...

 

        // Get the proxy of the axis
        CComPtr<WorkAxisProxy> pNodeWAZProxy ;
        ZAxisArray[1]->get_Item(2,(IDispatch**)&pNodeWAZProxy);

        CComPtr<TransientGeometry> pTransGeom = theApp.GetTransGeomPtr () ;    

        LinePtr pLine = pNodeWAZProxy->GetLine();
        PointPtr pLineRoot = pLine->GetRootPoint();
        UnitVectorPtr pLineDir = pLine->GetDirection();
        CComPtr <Vector> pvecDir  ;
        hRes = pLineDir->AsVector(&pvecDir);
        if (FAILED(hRes)) {
            gLogger.Printf(ekErrMsg, "Could not get AsVector");
            return;
        }

        CComPtr <Line> pZAxis;
        hRes = pTransGeom->CreateLine  (pLineRoot,pvecDir,&pZAxis);
        if (FAILED(hRes)) {
            gLogger.Printf(ekErrMsg, "Could not CreateLine");
            return;
        }

        CComPtr<Point> pOrigin;
        CComPtr<Point> p1;
        CComPtr<Point> p2;

        pTransGeom->CreatePoint(0, 0, 0, &pOrigin);
        pTransGeom->CreatePoint(1, 0, 0, &p1);
        pTransGeom->CreatePoint(0, 1, 0, &p2);

        CComPtr<Plane> pGeomXYPlane;
        hRes = pTransGeom->CreatePlaneByThreePoints(pOrigin, p1, p2, &pGeomXYPlane);
        if (FAILED(hRes)) {
            gLogger.Printf(ekErrMsg, "Could not CreatePlane");
            return;
        }

        CComPtr <ObjectsEnumerator> pObjEnum;
        hRes = pTransGeom->CurveSurfaceIntersection(pZAxis, pGeomXYPlane, 0.1, &pObjEnum);
        if (FAILED(hRes)) {
            gLogger.Printf(ekErrMsg, "Could not surface intersection");
            return;
        }

        TRACE ("There are %d intersections...\n",pObjEnum->Count);

        if (pObjEnum->Count < 1) {
            gLogger.Printf(ekErrMsg, "No intersections found...");
            return;
        }

        CComPtr <Point> pIntersectionPoint;
        hRes = pObjEnum->get_Item(1,(IDispatch**)&pIntersectionPoint);
        if (FAILED(hRes)) {
            gLogger.Printf(ekErrMsg, "Could not get intersection point");
            return;
        }

        TRACE("Intersection at %.2f %.2f %.2f \n",
              pIntersectionPoint->GetX(),
              pIntersectionPoint->GetY(),
              pIntersectionPoint->GetZ());

        CComPtr<WorkPoints> pWorkPoints;
        hRes =pAssemblyCompDef->get_WorkPoints(&pWorkPoints);
        if (FAILED(hRes)) {
            gLogger.Printf(ekErrMsg, "Could not get work points");
            return;
        }

        CComPtr <WorkPoint> pInterWorkPoint;
        pWorkPoints->AddFixed (pIntersectionPoint,FALSE,&pInterWorkPoint);
        if (FAILED(hRes)) {
            gLogger.Printf(ekErrMsg, "AddFixed point failed");
            return;
        }

        CComBSTR bstrPointName("ZeroPoint");
        hRes = pInterWorkPoint->put_Name(bstrPointName);
        if (FAILED(hRes)) {
            gLogger.Printf(ekErrMsg, "AddFixed point failed");
            return;
        }

Lots of error checking and C++ is more verbose than VB, but it is like your solution...

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

Post to forums  

Autodesk Design & Make Report