PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2017-12-22 11:05:33

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

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

x
CATIA二次开发入门教程---19 创建一条线( P. `6 q' }" Q3 v2 l2 h
/ @* ?1 e+ {* I; x
[mw_shl_code=c,true]
: m/ ]! e8 V/ a" e5 l1 O6 Z9 f4 f        CATFrmEditor *pEditor = CATFrmEditor::GeTCurrentEditor();
( t) p+ R  |9 d- y* p2 X; P9 m        CATDocument *pDoc = pEditor->GetDocument();
) D6 B3 t0 z4 d+ \8 R1 I5 a9 L, x        CATIContainerOfDocument_var spConOfDoc = pDoc;  P( d- j9 k. C2 l( A4 q1 X
        if (spConOfDoc == NULL_var)8 f3 S: I( c/ U$ f' s- d
        {4 L7 ?% t2 l% _5 x& Q( h$ p
                popUpNotifyDialog("No spConainer of document");5 D' _1 B) }3 J8 F& J( j9 V3 [) n
        }+ ~8 X+ S; f9 B9 `
        CATIContainer *pCon = NULL;
3 ]4 \& @, _! |( {9 B        HRESULT hr = spConOfDoc->GetSpecContainer(pCon);
" x! r* V, R" C2 N3 G" G% k5 t
% m" P" ]4 ^" ?8 d        //get GSM factory7 K4 v& M/ L% _4 n$ v$ V

0 t# r# R$ }' h, _. p    CATMathPoint p1,p2;% q/ `+ L* j& j" U
        p1.SetCoord(0,0,0);- O; ^& e; A, ]7 M8 c7 ?
        p2.SetCoord(10,10,10);
& _0 O  [& t( g8 Y. ]7 e# Q- s; M% t  g7 ^       
* K1 h# M4 K- C' M( [2 l3 T
! c- H* s1 h/ Z* O5 i" M     CATIGSMFactory_var spGSMFactory = pCon;3 Y2 G6 E! m5 x
  2 t- A( K& m" E# O2 c- h' {7 e
         CATIGSMPoint_var  spP1 = spGSMFactory->CreatePoint(p1,"");6 Q  t5 |+ j( O4 O1 p' P1 f2 z
         CATIGSMPoint_var  spP2 = spGSMFactory->CreatePoint(p2,"");' }1 `1 q% }) v! l. }5 P& z9 {$ R
     
+ c! i0 |$ k6 G  g9 w1 v. F6 G  CATIGSMLinePtPt_var spLine =  spGSMFactory->CreateLine(spP1,spP2,NULL_var);
  z/ p9 u2 O! l
& ?( l  O- R2 p" B$ I  CATISpecObject_var spSpecObject = spLine;8 u: p9 t' }" t* c; V
  CATIGSMProceduralView_var spGSMProceduralView = spSpecObject;% Q8 F' b9 o3 Q

( a/ ]  \9 m- b5 |  C! q. ^) x  spGSMProceduralView->InsertInProceduralView();! h2 L- S: d( e" q

' f8 Y4 H# b+ ~9 O" d7 G  spSpecObject->Update();[/mw_shl_code]
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 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();
; O; ]: a) b4 }2 d: g2 }) u, b
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复 支持 反对

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了