查看: 4026|回复: 1

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

[复制链接]

4

主题

3

回帖

44

积分

管理员

积分
44
发表于 2017-12-22 11:05:33 | 显示全部楼层 |阅读模式

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

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

×
CATIA二次开发入门教程---19 创建一条线
$ T! _' x) B6 K. M3 X8 V, T+ D2 h
7 D; V" F  `. z* n0 `# W2 e5 }$ P7 }( {[mw_shl_code=c,true], f0 X7 p; z- |8 M! t) V
        CATFrmEditor *pEditor = CATFrmEditor::GeTCurrentEditor();
: a6 f7 c. `6 o  B+ ~        CATDocument *pDoc = pEditor->GetDocument();
, c1 F1 N0 U- b( P( _- T        CATIContainerOfDocument_var spConOfDoc = pDoc;4 a+ G, a: z8 ^4 z" h
        if (spConOfDoc == NULL_var)
3 B8 r: w( }# G' U/ f        {
0 J+ Z5 x) x* s, c' i+ S                popUpNotifyDialog("No spConainer of document");
7 v  o5 r- c, u5 s5 Z        }
* r, \1 y! r5 |* a        CATIContainer *pCon = NULL;/ a2 {, R& |4 a7 w/ o
        HRESULT hr = spConOfDoc->GetSpecContainer(pCon);! I; t0 r  e1 F- |2 k/ P
* y, {8 m" Z2 }; Z0 v2 d1 L. G
        //get GSM factory' E* A9 r! D- @! O* _! C9 \" m

$ X4 U( _9 j. j9 C    CATMathPoint p1,p2;. r6 ^) P+ r: S; F, B! @4 G2 g4 e
        p1.SetCoord(0,0,0);' b, N1 X2 \1 H+ z+ c) ~% ]
        p2.SetCoord(10,10,10);7 [, [. h) }$ \( S6 p8 G- F0 U
       
! M, Z1 C' J. C* w  c. M% I
" i! p% X! n% o- O  N     CATIGSMFactory_var spGSMFactory = pCon;8 j2 b' n( |- @7 Y1 F9 i) _: j
  - P6 ^6 S) g2 R( r! k
         CATIGSMPoint_var  spP1 = spGSMFactory->CreatePoint(p1,"");
; D7 d& p. Q0 g/ c$ R; |* w( }: B         CATIGSMPoint_var  spP2 = spGSMFactory->CreatePoint(p2,"");0 P# O0 a" [) ]
     ( N( Q0 A: S: N) D
  CATIGSMLinePtPt_var spLine =  spGSMFactory->CreateLine(spP1,spP2,NULL_var);, V1 z( \( Q9 `4 g" {
. A7 o6 N3 z# C* G3 ~
  CATISpecObject_var spSpecObject = spLine;( Z: |4 \) g/ L5 `, d6 u/ O8 q
  CATIGSMProceduralView_var spGSMProceduralView = spSpecObject;
! _$ L" r+ ]5 Y# ?  ^( n* g( J! g2 s7 _6 _/ [5 ~
  spGSMProceduralView->InsertInProceduralView();9 f% e9 J* o9 q/ b' N9 u3 ?1 h
5 ]" `- z2 A- a% |# h0 s
  spSpecObject->Update();[/mw_shl_code]
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

4

主题

3

回帖

44

积分

管理员

积分
44
 楼主| 发表于 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();
9 k! g( q8 |# ^. R- t
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

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

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部