Add a WorkPoint into an assembly programatically

Top  Previous  Next

Here's how to do it, but note that the point added is totally unconstrained:

 

    CComPtr<WorkPoints> pWorkPointsList ;

    hRes = pAssemblyCompDef->get_WorkPoints (&pWorkPointsList) ;

 

    CComPtr<Point> pPt; // Create a 3d point

    hRes = GetTransGeomPtr()->CreatePoint(kStart[XI],kStart[YI],kStart[ZI],&pPt);

 

    hRes = pWorkPointsList->AddFixed (pPt,FALSE) ;

 

There's no error checking in the above code.

 

To do it manually you need to create a point which is the intersection of 3 planes (x y z). The planes can be offset of course so you are able to put the plane anywhere in 3D space.

 

Here is code which illustrates putting it at the start of an axis and setting its name:

 

       // Get the geometry of the axis..

       LinePtr pLine = pNodeWAZProxy->GetLine() ;

       PointPtr pProxyOrigin = pLine->RootPoint ;

       UnitVectorPtr pDir = pLine->Direction ;

 

       // You can get hold of the double values like this...

       TRACE("pos = %.3f, %.3f, %.3f, dir = %.3f, %.3f, %.3f,\n",

             pProxyOrigin->GetX(),pProxyOrigin->GetY(),pProxyOrigin->GetZ(),

             pDir->GetX(), pDir->GetY(), pDir->GetZ());

 

       CComPtr<WorkPoints> pWorkPointsList ;

       hRes = pCctsAssemblyCompDef->get_WorkPoints (&pWorkPointsList) ;

       CComPtr<Point> pPt; // Create a 3d point

       hRes = GetTransGeomPtr()->CreatePoint(pProxyOrigin->GetX(),

                                                    pProxyOrigin->GetY(),

                                                    pProxyOrigin->GetZ(),&pPt);

       CComPtr <WorkPoint> pWorkPoint;

       hRes = pWorkPointsList->AddFixed (pPt,FALSE,&pWorkPoint) ;

 

       const CTime kNow = CTime::GetCurrentTime ();

       CString csPointName;

       csPointName.Format(L"TUBO_%d_%d", kNow.GetSecond(), rand());

 

       CComBSTR bstrName(csPointName);

 

       pWorkPoint->put_Name(bstrName);

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)