PLM之家PLMHome-国产软件践行者

[资料] CATIA二次开发入门教程---19 创建一条线

[复制链接]

2017-12-22 11:06:27 3670 1

admin 发表于 2017-12-22 11:05:33 |阅读模式

admin 楼主

2017-12-22 11:05:33

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
CATIA二次开发入门教程---19 创建一条线
5 I" r- H' b8 ~1 W8 k8 K4 Z/ p1 _/ }& l5 F8 W) P* l4 l, @
[mw_shl_code=c,true]
' O6 Z/ t$ ~$ b" J        CATFrmEditor *pEditor = CATFrmEditor::GeTCurrentEditor();
0 ], D2 [# Z2 y  q; W        CATDocument *pDoc = pEditor->GetDocument();# X/ _! V$ ~  J9 t% q
        CATIContainerOfDocument_var spConOfDoc = pDoc;5 j) S1 b6 z; b- L4 |& |6 h  {9 {
        if (spConOfDoc == NULL_var)7 f7 ^8 i1 s) f
        {
3 o7 t3 z; N2 Z; |                popUpNotifyDialog("No spConainer of document");. [/ f2 J1 O7 l
        }
2 l1 C2 j6 d: _        CATIContainer *pCon = NULL;
5 W+ f7 j, I- j        HRESULT hr = spConOfDoc->GetSpecContainer(pCon);
3 c+ v$ F7 Y8 S! J% ~6 R& i& B7 V0 Z" z0 x3 F6 K
        //get GSM factory5 L' d# h: D, t; m. _
+ E+ \% W: w1 A. Y6 E5 k
    CATMathPoint p1,p2;# s1 {5 I+ w$ I& s
        p1.SetCoord(0,0,0);. @+ N1 P* ^( w# f, n2 r5 p8 f
        p2.SetCoord(10,10,10);# Y- m* Q/ q: X! A% ^- S
        5 H( V- f6 S, _  x& S# f! J* s
7 D9 T. O1 `# @# y8 M5 l
     CATIGSMFactory_var spGSMFactory = pCon;, k( Y2 @8 \/ ^8 }; |! k8 ^+ {! P
  
# @. G4 I9 f: z5 h1 N8 _: x7 G         CATIGSMPoint_var  spP1 = spGSMFactory->CreatePoint(p1,"");" K, r# @% i' y2 s5 |2 o: [7 I5 F& G; o
         CATIGSMPoint_var  spP2 = spGSMFactory->CreatePoint(p2,"");
8 k) }1 o8 g3 W! D6 M: Z2 l     
. e  W( |" O; U2 H  CATIGSMLinePtPt_var spLine =  spGSMFactory->CreateLine(spP1,spP2,NULL_var);
& A/ ~0 F6 `" }* T
7 |3 A. E* Z" f' Y( ^  CATISpecObject_var spSpecObject = spLine;
( L( _$ O: S' ]' }; R  CATIGSMProceduralView_var spGSMProceduralView = spSpecObject;" E4 i1 I& m0 Y1 M1 I" Y3 f, @
6 {& q4 R( B; l$ w" x6 {' c
  spGSMProceduralView->InsertInProceduralView();) c, j7 W  D' Z* P

, Z3 P. y) I) ]3 r4 R  spSpecObject->Update();[/mw_shl_code]
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

全部回复1

admin 发表于 2017-12-22 11:06:27

admin 沙发

2017-12-22 11:06:27

在此基础上,创建线的步骤如下:
1)创建两个点并将其转换为CATISpecObjects。
double Coords[3];
Coords[0] = 0;
Coords[1] = 0;
Coords[2] = 0;
CATIGSMPoint_var spPoint1 = spGSMFactory->CreatePoint(Coords); CATISpecObject_var spSpecPoint1 = spPoint1;                  
Coords[0] = 8;
Coords[1] = 6;
Coords[2] = 7;
CATIGSMPoint_var spPoint2 = spGSMFactory->CreatePoint(Coords);
CATISpecObject_var spSpecPoint2 = spPoint2;
2) 利用创建的点创建一条线,并将其转换为CATISpecObject
CATISpecObject_var  spSupport = NULL_var;
CATIGSMLinePtPt_var spLine1 = spGSMFactory->CreateLine(spSpecPoint1, spSpecPoint2, spSupport);
CATISpecObject_var spSpecLine1 = spLine1;
3) 更新创建的线,并将其添加到视图中。
spSpecLine1->Update();
CATIGSMProceduralView_var spCurObj = spLine1;
spCurObj->InsertInProceduralView();

8 d$ z/ z* S  ^  D/ ]& i0 G
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了