查看: 4223|回复: 1

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

[复制链接]

2480

主题

1280

回帖

8万

积分

管理员

PLM之家站长

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

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

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

×
CATIA二次开发入门教程---19 创建一条线
4 z+ f; T# ?. Q+ u. z2 F
$ {( d9 Y8 k7 o[mw_shl_code=c,true]
- z+ W- `; @8 r* e& [3 \" D        CATFrmEditor *pEditor = CATFrmEditor::GeTCurrentEditor();
) H! Q# K- G9 V9 h8 E        CATDocument *pDoc = pEditor->GetDocument();
; b+ a3 W( |/ Y( _; v% r: P# h: k        CATIContainerOfDocument_var spConOfDoc = pDoc;
3 J+ N+ K% \' s        if (spConOfDoc == NULL_var)6 o0 A; S5 x: @9 s3 N1 a5 O3 f' S
        {$ J3 {/ e2 l6 N6 G
                popUpNotifyDialog("No spConainer of document");
5 t$ h4 A& F, ~        }8 v) O2 ^/ A. Y" f% k
        CATIContainer *pCon = NULL;
5 E0 L8 C8 c) g, r: ]3 \; H        HRESULT hr = spConOfDoc->GetSpecContainer(pCon);& z: L7 E% h& _. G) d7 r
+ b3 L4 s* W# x. R. `; k
        //get GSM factory- r! ^6 m5 s. n2 Q3 s/ O: @' n! y8 p+ s

: G# g+ w% g. k0 ?2 o2 {    CATMathPoint p1,p2;* D$ ]1 _0 G3 l" k
        p1.SetCoord(0,0,0);
7 |8 h7 p, n9 M. M        p2.SetCoord(10,10,10);
2 S2 N3 p6 e7 H        * c) o5 L9 B: r
. \4 U: G( C2 q1 k5 f4 O+ m  q
     CATIGSMFactory_var spGSMFactory = pCon;6 z4 m) I6 s- q2 e" C
  
( J# ^& @* H" ~! W         CATIGSMPoint_var  spP1 = spGSMFactory->CreatePoint(p1,"");
; |( `) K0 _" i         CATIGSMPoint_var  spP2 = spGSMFactory->CreatePoint(p2,"");6 v; f2 T0 P% q( y( R5 E
     
4 w- O2 h$ a' n4 |5 A  CATIGSMLinePtPt_var spLine =  spGSMFactory->CreateLine(spP1,spP2,NULL_var);
0 Q( V! s# G  X; E) B- f1 k: R
* ~: r1 N. f7 z4 b; Q6 x  CATISpecObject_var spSpecObject = spLine;3 C$ U& I9 X% u* a3 d
  CATIGSMProceduralView_var spGSMProceduralView = spSpecObject;
! S! t3 [( V: j% O% U4 d  n: P
$ a5 E! n8 p' J: P; L6 b) B  spGSMProceduralView->InsertInProceduralView();$ A/ Q& q- O. K

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

使用道具 举报

2480

主题

1280

回帖

8万

积分

管理员

PLM之家站长

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

6 Y6 t! Y0 z4 v3 p$ I$ ?1 Z
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复 支持 反对

使用道具 举报

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

本版积分规则

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