weijinquan1233 发表于 2016-10-30 15:55:26

UG利用UI创建块 圆柱

               创建块
                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();

Jefft* 发表于 2016-10-30 16:42:14

可以直接doubleLength->Value(),代码会更简洁。
在对应的类中,有这个成员函数。只有极个别的没有对应的函数来获取UI的值。

weijinquan1233 发表于 2016-10-31 11:08:40

Jefft 发表于 2016-10-30 16:42
可以直接doubleLength->Value(),代码会更简洁。
在对应的类中,有这个成员函数。只有极个别的没有对应的 ...

那个圆锥能帮我看看咋回事啊   现在还是没搞对
页: [1]
查看完整版本: UG利用UI创建块 圆柱