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...
Solved! Go to Solution.
Solved by oransen. Go to Solution.
Solved by HermJan.Otterman. Go to Solution.
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.
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
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.