iCAx开思网

标题: 如何得到草图里的直线 [打印本页]

作者: lansehaiyu    时间: 2012-12-9 11:01
标题: 如何得到草图里的直线
我想获取图中草图的直线.4,下面是我写的代码,可是我得到却是绝对轴里的横向和纵向两条线。
[attach]1153043[/attach]
//得到草图底部的直线
   CATIDescendants * piSketPart = NULL;
   rc=spSketchFeat->QueryInterface(IID_CATIDescendants,(void **)& piSketPart);
   if (SUCCEEDED(rc))
   {
    cout<<"查询CATIDescendants成功"<<endl;
   }
   else
    cout<<"查询CATIDescendants失败"<<endl;
   CATLISTV(CATISpecObject_var) lineList;
   piSketPart->GetAllChildren("CATCurve",lineList);
   int lineNum = lineList.Size();
   cout<<"直线的个数为"<<lineNum<<endl;
   CATISpecObject * spLineFeat= NULL;
   CATLine * piButtonLine = NULL;
   for (int i=1;i<=lineNum;i++)
   {
    spLineFeat = lineList;
    if (NULL_var != spLineFeat)
    {
     cout<<"spLineFeat不为空"<<endl;
     CATCurve * piLine= NULL;
     rc=spLineFeat->QueryInterface(IID_CATCurve,(void **)& piLine);
     if (SUCCEEDED(rc))
     {
      cout<<"查询CATLine成功"<<endl;
      CATIAlias * piLineAlias = NULL;
      if (SUCCEEDED(spLineFeat->QueryInterface(IID_CATIAlias,(void **)&piLineAlias)))
      {
       cout<<"查询CATIAlias成功"<<endl;
       CATUnicodeString LineName=piLineAlias->GetAlias();
       cout<<LineName<<endl;
       const CATUnicodeString ButtonLineName = "直线.4";
       if (LineName == ButtonLineName)
       {
        piButtonLine = piLine;
       }
       if (NULL != piButtonLine)
       {
        cout<<"piButtonLine不为空"<<endl;
       }
      }
      piLineAlias->Release();
      piLineAlias = NULL;
     }
    }
   }
作者: linlily0925    时间: 2012-12-10 09:44
你得到草图下的每一个元素,然后用CATISpecObjet->GetType()方法,看看草图里面直线的类型,然后反过来再通过这个类型和名字过滤就可以得到了~~~如果我记得不错的话,好像是CATI2DLine




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3