QQ登录

只需一步,快速开始

快捷登录

登录 或者 注册 请先

UG爱好者

查看: 2006|回复: 2
打印 上一主题 下一主题

[分享] UG利用UI创建块 圆柱

[复制链接]

上等兵

Rank: 1

2

主题

8

帖子

85

积分
跳转到指定楼层
楼主
发表于 2016-10-30 15:55:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
               创建块
                Part *workpart(theSession->Parts()->Work());
                NXString length,width,height;
               
                Point3d origin=this->point0->GetProperties()->GetPoint("Point");
                double lengthValue =this->doubleLength->GetProperties()->GetDouble("Value");
                double widthValue =this->doubleWidth->GetProperties()->GetDouble("Value");
                double heightValue =this->doubleHeight->GetProperties()->GetDouble("Value");

                std::stringstream slength;
                slength<<lengthValue;
                length=slength.str();

                std::stringstream swidth;
                swidth<<widthValue;
                width=swidth.str();

                std::stringstream sheight;
                sheight<<heightValue;
                height=sheight.str();

                Features::Feature *null_block_feature(NULL);
                Features::BlockFeatureBuilder *blockfeaturebuilder;
                blockfeaturebuilder=workpart->Features()->CreateBlockFeatureBuilder(null_block_feature);
                blockfeaturebuilder->SetOriginAndLengths(origin,length,width,height);
                //commit
                blockfeaturebuilder->CommitFeature();
                //destroy
                blockfeaturebuilder->Destroy();

               创建圆柱
                NXString diamerString,heihtString;
                std::stringstream ssdia,ssheight;
               

                BlockStyler::PropertyList*vectorProperty=vector0->GetProperties();
                Vector3d vec=vectorProperty->GetVector("Vector");
                delete vectorProperty;
                vectorProperty=NULL;

                BlockStyler::PropertyList*pointProperty=point0->GetProperties();
                Point3d point=pointProperty->GetPoint("Point");
                delete pointProperty;
                pointProperty=NULL;

                BlockStyler::PropertyList*diaProperty=expressionDia->GetProperties();
                double dia=diaProperty->GetDouble("Value");
                delete diaProperty;
                diaProperty=NULL;
               
                BlockStyler::PropertyList*heightProperty=expressionH->GetProperties();
                double height=heightProperty->GetDouble("Value");
                delete heightProperty;
                heightProperty=NULL;

                ssdia<<dia;
                diamerString=ssdia.str();

                ssheight<<height;
                heihtString=ssheight.str();
                //create the cylinder feature
                 
                 Part *workPart(theSession->Parts()->Work());
                 Part *displayPart(theSession->Parts()->Display());
               
         Features::Feature *nullNXOpen_Features_Feature(NULL);

                 Features::CylinderBuilder *cylinderBuilder1;
                 cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(nullNXOpen_Features_Feature);
                 cylinderBuilder1->Diameter()->SetRightHandSide(diamerString);
                 cylinderBuilder1->Height()->SetRightHandSide(heihtString);
                 cylinderBuilder1->SetDirection(vec);
                 cylinderBuilder1->SetOrigin(point);
                 cylinderBuilder1->CommitFeature();
                 cylinderBuilder1->Destroy();

有奖推广贴子: 

回复

使用道具 举报

贵宾

Rank: 9Rank: 9Rank: 9

14

主题

265

帖子

8251

积分

论坛技术员论坛贡献

沙发
发表于 2016-10-30 16:42:14 | 只看该作者
可以直接doubleLength->Value(),代码会更简洁。
在对应的类中,有这个成员函数。只有极个别的没有对应的函数来获取UI的值。
回复 支持 反对

使用道具 举报

上等兵

Rank: 1

2

主题

8

帖子

85

积分
板凳
 楼主| 发表于 2016-10-31 11:08:40 | 只看该作者
Jefft 发表于 2016-10-30 16:42
可以直接doubleLength->Value(),代码会更简洁。
在对应的类中,有这个成员函数。只有极个别的没有对应的 ...

那个圆锥能帮我看看咋回事啊   现在还是没搞对
回复 支持 反对

使用道具 举报

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

本版积分规则

 
 
QQ:1359218528
工作时间:
9:00-17:00
 
微信公众号
手机APP
机械社区
微信小程序

手机版|UG爱好者论坛 ( 京ICP备10217105号-2 )    论坛管理员QQ:1359218528

本站信息均由会员发表,不代表本网站立场,如侵犯了您的权利请联系管理员,邮箱:1359218528@qq.com  

Powered by UG爱好者 X3.2  © 2001-2014 Comsenz Inc. GMT+8, 2024-4-29 08:29

返回顶部