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

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

[复制链接]

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

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

admin 楼主

2017-12-22 11:05:33

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

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

x
CATIA二次开发入门教程---19 创建一条线
' L5 [! i, U" ~  u) ?! S' b  Z  p3 a
[mw_shl_code=c,true]
; N7 R  i% ]4 |9 V# {( |; }        CATFrmEditor *pEditor = CATFrmEditor::GeTCurrentEditor();
) z, t" V8 c! V7 u+ O$ w' @/ O        CATDocument *pDoc = pEditor->GetDocument();
5 u5 l  [! g  r1 X        CATIContainerOfDocument_var spConOfDoc = pDoc;4 P# K& D+ T3 O5 p: n8 P
        if (spConOfDoc == NULL_var)
  B0 h4 I8 M! a" S+ Q        {7 f% ?9 c% M: @' t
                popUpNotifyDialog("No spConainer of document");  @: i! u4 s/ U, q) T9 \
        }5 \0 F- Y/ Z! b$ n2 I8 F6 Y
        CATIContainer *pCon = NULL;- W8 m% W% _; [2 x) L: ?' X  {0 f% G
        HRESULT hr = spConOfDoc->GetSpecContainer(pCon);$ ?2 Y9 X" g$ B) p0 O! i; |- S

' R% ^, I9 H- B" L" L+ ?        //get GSM factory
0 k4 x- y. m  b* v
' U8 W  M7 c1 \6 f0 ~! Z    CATMathPoint p1,p2;
& u, l0 \9 |% K5 Y5 z% ~: {        p1.SetCoord(0,0,0);
* [0 z! m4 f% t- U' ]. N7 \% g        p2.SetCoord(10,10,10);
/ U' Y" v+ r; C, P8 `) X        5 c# t# Q5 e+ K# I3 s
( z1 r8 @+ E! I& J- O' u+ z8 ?
     CATIGSMFactory_var spGSMFactory = pCon;. j$ p# w! L+ k+ r+ c% w1 d
  8 J7 y. f3 W! F  _: G% `
         CATIGSMPoint_var  spP1 = spGSMFactory->CreatePoint(p1,"");& z+ R; O: |  q3 w- @) i( n' B! g& S
         CATIGSMPoint_var  spP2 = spGSMFactory->CreatePoint(p2,"");) N: \/ n7 N8 m0 {2 K4 o6 z
     3 ^, j0 b1 Y4 G; O. P
  CATIGSMLinePtPt_var spLine =  spGSMFactory->CreateLine(spP1,spP2,NULL_var);
5 j; K8 S* W" m: f) R% A& k9 X7 n
3 z+ x9 |: {$ h& M5 ~5 [  CATISpecObject_var spSpecObject = spLine;
& \+ t. V! G, [& z1 h8 m  CATIGSMProceduralView_var spGSMProceduralView = spSpecObject;
) g' C) {) l" Z* r# ~, i8 I3 x0 y
( x1 }2 I2 _  k; ~8 `  spGSMProceduralView->InsertInProceduralView();" g9 x3 n- u) P! ?) ^- M# n% I

! B& q3 R2 }9 Q% s4 `: w# X  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();
, ]3 n: t* H) M! I; F8 ]
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了