查看: 4072|回复: 1

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

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

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

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

×
CATIA二次开发入门教程---19 创建一条线, r, |+ b. o8 z# Q; A5 N

5 ~/ L  k8 Y4 K1 _; K[mw_shl_code=c,true]
; Y: j9 G* K2 K3 }9 n) i. W        CATFrmEditor *pEditor = CATFrmEditor::GeTCurrentEditor();
' h3 x, ^( p5 K; J5 [4 L. |        CATDocument *pDoc = pEditor->GetDocument();
" E" F7 Y# }" ]3 ]        CATIContainerOfDocument_var spConOfDoc = pDoc;
& d4 H+ D9 Z5 ?6 h4 J        if (spConOfDoc == NULL_var)
$ z6 s- X& r# U, L, e) y8 ^        {
- U5 R3 ^/ c9 Q5 c+ E6 o3 _5 J                popUpNotifyDialog("No spConainer of document");
' |) C* W5 x/ S* ~* k; F        }; w' @" M" Q; d8 @. m3 k5 v( y
        CATIContainer *pCon = NULL;1 [' o/ H2 ~# h8 Z) ]/ @
        HRESULT hr = spConOfDoc->GetSpecContainer(pCon);2 Q! J3 X. ]6 \

& I; q. q% _- W        //get GSM factory
" G1 d) Q# L, \. t3 F$ l  G+ {7 H6 A- L: h
    CATMathPoint p1,p2;2 B7 T4 X3 f, ^# B
        p1.SetCoord(0,0,0);7 s( x4 b8 p/ N6 f& w) a; `
        p2.SetCoord(10,10,10);
$ {/ k( A, g: q0 T        ! S2 v, A8 P. B) {% [
4 Y- d% M0 ^. w2 K! O
     CATIGSMFactory_var spGSMFactory = pCon;
6 U5 }$ m2 ]" Z; i. \) A4 D" a$ N  1 ^4 L: }, X# N
         CATIGSMPoint_var  spP1 = spGSMFactory->CreatePoint(p1,"");
9 e1 c* F0 `% T0 J) G         CATIGSMPoint_var  spP2 = spGSMFactory->CreatePoint(p2,"");
& M+ d* n( y1 E       f# J, A3 U0 J5 A( y" a- D
  CATIGSMLinePtPt_var spLine =  spGSMFactory->CreateLine(spP1,spP2,NULL_var);8 p7 s- F# e& F& W2 k5 b) l
# \8 D8 d4 G# T+ }5 @0 f
  CATISpecObject_var spSpecObject = spLine;! t, k/ q4 D- Q; U
  CATIGSMProceduralView_var spGSMProceduralView = spSpecObject;
; C$ J, H. S' r/ b7 s
8 A7 K0 L/ N" F9 O  O, s! _* o9 R) q  spGSMProceduralView->InsertInProceduralView();9 F( D2 w6 q3 d7 @9 L
0 h3 v( w* l8 K- e: F
  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();
$ z, P+ f+ S3 r  p$ g8 f3 R4 G' D: S8 U
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

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

本版积分规则

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