查看: 4123|回复: 1

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

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

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

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

×
CATIA二次开发入门教程---19 创建一条线; p6 ?1 i) q, D( {; A+ x
7 c" R6 W0 v) d/ k- \" Q/ }) s
[mw_shl_code=c,true]8 h" K, p' N& k" Y) _+ n+ {
        CATFrmEditor *pEditor = CATFrmEditor::GeTCurrentEditor();
% g; F  x: x2 I( L4 ]$ a) G        CATDocument *pDoc = pEditor->GetDocument();
4 X% [( s8 A& \2 k# D5 x) T: S        CATIContainerOfDocument_var spConOfDoc = pDoc;
3 _8 N) W- A( |# W0 B7 d- p5 f5 D8 E        if (spConOfDoc == NULL_var)# ^3 x  z/ }" N! i4 X
        {
6 E! l+ n0 D" {1 c                popUpNotifyDialog("No spConainer of document");0 a- u  r) ^  L# l, A
        }1 @6 z; c4 j; }; k
        CATIContainer *pCon = NULL;
$ m* c+ B+ m: `        HRESULT hr = spConOfDoc->GetSpecContainer(pCon);7 M, B5 O- Z+ [: o

; A, A* T1 r4 I9 f4 K        //get GSM factory. D$ v1 j" z5 a# ?
+ e4 O8 ?2 P& e. u
    CATMathPoint p1,p2;
- C# b  {, g+ q& ^" a# K        p1.SetCoord(0,0,0);" ?; J* C) m& J5 u7 f& x: J/ l# Z$ V
        p2.SetCoord(10,10,10);
5 O1 i* ]; s: s  `5 n+ n       
4 }* E( f4 E2 p: S5 t. C7 l6 W& e3 ~4 D
     CATIGSMFactory_var spGSMFactory = pCon;
! a# Y/ n) e; T: z( Y! s/ G  * j! A5 x( C7 K; s
         CATIGSMPoint_var  spP1 = spGSMFactory->CreatePoint(p1,"");) K/ D9 r& b0 q% ?( ~
         CATIGSMPoint_var  spP2 = spGSMFactory->CreatePoint(p2,"");0 z* @  p+ ]- A# g+ e3 Q
     4 Q5 J0 |: C* P: I; F
  CATIGSMLinePtPt_var spLine =  spGSMFactory->CreateLine(spP1,spP2,NULL_var);4 d1 {6 C. x9 K6 H$ \
' J! h( {0 t$ {& G" d; |% N$ ~
  CATISpecObject_var spSpecObject = spLine;
6 g( ]: ~, a: y4 r4 ?9 j. _3 |* w3 m  CATIGSMProceduralView_var spGSMProceduralView = spSpecObject;) o, e8 P6 _! D7 q' c
$ D. P, V" V0 }0 U+ f8 o
  spGSMProceduralView->InsertInProceduralView();/ S4 Y/ `% u) Z: O; }6 \$ Y# H

! @" ~' ~/ H1 f/ j- m, A  spSpecObject->Update();[/mw_shl_code]
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

6

主题

4

回帖

60

积分

管理员

积分
60
 楼主| 发表于 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();

( Y2 I$ O% v, q  G; M/ i- T
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

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

本版积分规则

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