UG二次开发之Open和NXOpen

上传人:汽*** 文档编号:563385461 上传时间:2023-01-23 格式:DOC 页数:4 大小:28.50KB
返回 下载 相关 举报
UG二次开发之Open和NXOpen_第1页
第1页 / 共4页
UG二次开发之Open和NXOpen_第2页
第2页 / 共4页
UG二次开发之Open和NXOpen_第3页
第3页 / 共4页
UG二次开发之Open和NXOpen_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《UG二次开发之Open和NXOpen》由会员分享,可在线阅读,更多相关《UG二次开发之Open和NXOpen(4页珍藏版)》请在金锄头文库上搜索。

1、OpenC、OpenC+和NXOpenC+混合开发三者的关系我在以前的文章中讲过了。但是他们都不是孤立的,互相可以使用。下面举了个不同部分用不同的代码,函数形式的是OpenC,也就是API了类形式不带NXOpen的是OpenC+,否则是NXOpenC+了。Tag是所有之间的桥梁。/NXOpenheaderfiles#include#include#include/#include#include#include#include#include/#include/UFuncHeaders#include#include#include#include/UGOpenheaders#include#

2、include#include#include#include#includeintmain(intargc,char*argv).interrorCode;/*/*Here,wecaninitializesessionusing:1. OpenCAPIenvironment2. OpenC+APIenvironment3. NXOpenC+APIs.Userhastoinitialize,UGSessionusingOpenC+aswellasNXOpenC+,sessionalso.*/*/*UsingOpenCAPI,wecaninitializeUGSessionasfollows*/

3、*/*errorCode=UF_initialize();if(0!=errorCode)returnerrorCode;*/NXOpen:Part*part1;/*/*UsingOpenC+API,wecaninitializeUGSessionasfollows*/UgSession:initialize();/*/*UsingNXOpenC+API,wecaninitializeUGSessionasfollows*/NXOpen:Session*theSession=NXOpen:Session:GetSession();/*/*Createanewpart.Tocreatenewpa

4、rtonecanuse:1. OpenCAPIenvironment2. OpenC+APIenvironment3. NXOpenC+APIs.*/char*partName=InteropWithOpenCOpenCPPAndNXOpenCPP.prt;/*/*UsingOpenCAPI,wecancreatenewpartasfollows*/*/*tag_tUF_partTag;UF_PART_new(partName,2,&UF_partTag);*/*/*UsingOpenC+API,wecancreatenewpartasfollows*/UgPart*UGPart=UgPart

5、:create(partName,Inches);/*/*UsingNXOpenC+API,wecancreatenewpartasfollows*/*/*NXOpen:NXStringpartName=InteropWithOpenCOpenCPPAndNXOpenCPP.prt;part1=theSession-GetParts()-NewDisplay(partName,NXOpen:Part:UnitsInches);*/InteropbetweenNXOpenC+APIsandOpenC/*/*CreatealineusingNXOpenC+APIs*/NXOpen:Point3dp

6、oint3d1(-2.17019791346668,1.13935390457001,0);NXOpen:Point3dpoint3d2(-0.714356813182783,1.13935390457001,0);NXOpen:Line*line1;line1=theSession-GetParts()-GetWork()-GetCurves()-CreateLine(point3d1,point3d2);/*/*RetrievelinecoordinatesusingOpenCAPI*/tag_tline_tag=line1-GetTag();UF_CURVE_line_tline_coo

7、rds;UF_CURVE_ask_line_data(line_tag,&line_coords);/InteropbetweenOpenC+andNXOpenC+APIsPoint3UGPt1(line_coords.start_point0+5,line_coords.start_point1+5,line_coords.start_point2+5);Point3UGPt2(line_coords.end_point0+5,line_coords.end_point1,line_coords.end_point2);UgLine*UGLine;UGLine=UgLine:create(U

8、GPt1,UGPt2);UgCoordSys*UGCoordsys;UGCoordsys=UgSession:getWCS();CoordSysSys=UGCoordsys-getCoordSys();/CreatingArcUgArc*OpenCPPArc=UgArc:create(5.0,0.25,3.14,Sys);tag_tarc_tag=OpenCPPArc-getTag();NXOpen:Arc*nxArc=(NXOpen:Arc*)NXOpen:NXObjectManager:Get(arc_tag);doublenxArc_radius=nxArc-GetRadius();do

9、ublenxArc_start_angle=nxArc-GetStartAngle();doublenxArc_end_angle=nxArc-GetEndAngle();/*/*Savethisworkpart.Tosavethisworkpartonecanuse:1. OpenCAPIenvironment2. OpenC+APIenvironment3. NXOpenC+APIs.*/*/*UsingOpenCAPI,wecansavethispartasfollows*/*/*UF_PART_save();*/*/*UsingOpenC+API,wecansavethispartas

10、follows*/*/*UGPart-save();*/*/*UsingNXOpenC+API,wecansavethispartasfollows*/*/*TogetthepartfromtheParttag*/part1=(NXOpen:Part*)NXOpen:NXObjectManager:Get(UGPart-getTag();/*/*TosaveworkpartusingNXOpenautomationAPIs*/NXOpen:PartSaveStatus*partSaveStatus;part1-Save(NXOpen:Part:SaveComponentsTrue,NXOpen:Part:CloseAfterSaveTrue,&partSaveStatus);/*/*TocloseallpartsusingNXOpenautomationAPIs*/theSession-GetParts()-CloseAll(NXOpen:Part:CloseModifiedCloseModified,NULL);/*/*TerminatethesessionusingOpenCAPI*/errorCode=UF_terminate();return0;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号