CATIA二次开发入门教程---19 创建一条线
CATIA二次开发入门教程---19 创建一条线CATFrmEditor *pEditor = CATFrmEditor::GetCurrentEditor();
CATDocument *pDoc = pEditor->GetDocument();
CATIContainerOfDocument_var spConOfDoc = pDoc;
if (spConOfDoc == NULL_var)
{
popUpNotifyDialog("No spConainer of document");
}
CATIContainer *pCon = NULL;
HRESULT hr = spConOfDoc->GetSpecContainer(pCon);
//get GSM factory
CATMathPoint p1,p2;
p1.SetCoord(0,0,0);
p2.SetCoord(10,10,10);
CATIGSMFactory_var spGSMFactory = pCon;
CATIGSMPoint_varspP1 = spGSMFactory->CreatePoint(p1,"");
CATIGSMPoint_varspP2 = spGSMFactory->CreatePoint(p2,"");
CATIGSMLinePtPt_var spLine =spGSMFactory->CreateLine(spP1,spP2,NULL_var);
CATISpecObject_var spSpecObject = spLine;
CATIGSMProceduralView_var spGSMProceduralView = spSpecObject;
spGSMProceduralView->InsertInProceduralView();
spSpecObject->Update(); 在此基础上,创建线的步骤如下:1)创建两个点并将其转换为CATISpecObjects。double Coords;Coords = 0;Coords = 0;Coords = 0;CATIGSMPoint_var spPoint1 = spGSMFactory->CreatePoint(Coords); CATISpecObject_var spSpecPoint1 = spPoint1; Coords = 8;Coords = 6;Coords = 7;CATIGSMPoint_var spPoint2 = spGSMFactory->CreatePoint(Coords);CATISpecObject_var spSpecPoint2 = spPoint2;2) 利用创建的点创建一条线,并将其转换为CATISpecObjectCATISpecObject_varspSupport = NULL_var; CATIGSMLinePtPt_var spLine1 = spGSMFactory->CreateLine(spSpecPoint1, spSpecPoint2, spSupport);CATISpecObject_var spSpecLine1 = spLine1;3) 更新创建的线,并将其添加到视图中。spSpecLine1->Update();CATIGSMProceduralView_var spCurObj = spLine1;spCurObj->InsertInProceduralView();
页:
[1]