Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In C++, DirectDesignType, Moving SketchLines, Arc, Circle in my following code Does Not Work.
It goes upto:
Ptr<MoveFeatureInput> moveFeatureInput = moveFeats->createInput(ObjectColl, transform);
But Skips the following line:
Ptr<MoveFeature> moveFeature = moveFeats->add(moveFeatureInput);
The my code is as below:
Regards,
Thurai.
extern "C" XI_EXPORT bool run(const char* context)
{
app = Application::get();
if (!app)
return false;
ui = app->userInterface();
if (!ui)
return false;
if (!ui)
return false;
Ptr<Documents> documents = app->documents();
if (!documents)
return false;
Ptr<Document> doc = documents->add(DocumentTypes::FusionDesignDocumentType);
if (!doc)
return false;
if (!doc)
return false;
//des = adsk.fusion.Design.cast(app.activeProduct),
Ptr<Product> product = app->activeProduct();
if (!product)
return false;
Ptr<Product> product = app->activeProduct();
if (!product)
return false;
Ptr<Design> design = product;
if (!design)
return false;
// In C++ Specifying Design Type: Set the value of the property, where value_var is a DesignTypes.
bool ReturnValue = design->designType(DirectDesignType);
if(!ReturnValue)
return false;
bool ReturnValue = design->designType(DirectDesignType);
if(!ReturnValue)
return false;
// Get the root component of the active design.
Ptr<Component> rootComp = design->rootComponent();
if(!rootComp)
return false;
Ptr<Component> rootComp = design->rootComponent();
if(!rootComp)
return false;
// Create a new sketch on the xy plane.
Ptr<Sketches> sketches = rootComp->sketches();
if (!sketches)
return false;
Ptr<ConstructionPlane> xyPlane = rootComp->xYConstructionPlane();
if (!xyPlane)
return false;
Ptr<Sketch> sketch = sketches->add(xyPlane);
if (!sketch)
return false;
if (!sketch)
return false;
Ptr<SketchCurves> sketchCurves = sketch->sketchCurves();
if(!sketchCurves)
return false;
if(!sketchCurves)
return false;
Ptr<SketchLines> sketchLines = sketchCurves->sketchLines();
if(!sketchLines)
return false;
if(!sketchLines)
return false;
Ptr<SketchCircles> sketchcCircles = sketchCurves->sketchCircles();
if (!sketchcCircles)
return false;
if (!sketchcCircles)
return false;
Ptr<SketchArcs> sketchArcs = sketchCurves->sketchArcs();
if (!sketchArcs)
return false;
ui->messageBox("Before bulkhead.sketchPoints");
// Get sketch texts
Ptr<SketchPoints> sketchPoints = sketch->sketchPoints();
if (!sketchPoints)
return false;
Ptr<SketchPoints> sketchPoints = sketch->sketchPoints();
if (!sketchPoints)
return false;
ui->messageBox(" After bulkhead.sketchPoints");
Ptr<Point3D> Pts[4];
Pts[0] = Point3D::create(0.0,0.0,0.0);
Pts[1] = Point3D::create(-10.0,0.0,0.0);
Pts[2] = Point3D::create(-10.0,-5,0.0);
Pts[1] = Point3D::create(-10.0,0.0,0.0);
Pts[2] = Point3D::create(-10.0,-5,0.0);
//sketchPoints
Ptr<SketchPoint> sketchPoint[4];
unsigned int I;
for (I = 0; I <= 2 ; I++)
{//I
sketchPoint[I] = sketchPoints->add(Pts[I]);
if(!sketchPoint[I])
return false;
}//I
{//I
sketchPoint[I] = sketchPoints->add(Pts[I]);
if(!sketchPoint[I])
return false;
}//I
string msg;
ui->messageBox(" After bulkhead.sketchPoints[I] 0 to 2 ");
ui->messageBox(" After bulkhead.sketchPoints[I] 0 to 2 ");
Ptr<SketchLine> MyLines[2];
MyLines[0] = sketchLines->addByTwoPoints( Pts[0], Pts[1]);
if(!MyLines[0])
return false;
if(!MyLines[0])
return false;
MyLines[1] = sketchLines->addByTwoPoints( Pts[1], Pts[2]);
if(!MyLines[1])
return false;
if(!MyLines[1])
return false;
Ptr<SketchArc> arc0 = sketchArcs->addFillet(MyLines[0], MyLines[0]->endSketchPoint()->geometry(), MyLines[1], MyLines[1]->startSketchPoint()->geometry(), 0.5);
if (!arc0)
return false;
Pts[3] = Point3D::create(-10.0,-5,0.0);
Ptr<SketchCircle> circle0 = sketchcCircles->addByCenterRadius(Pts[3], 1.0);
if (!circle0)
return false;
sketchPoint[3] = sketchPoints->add(Pts[3]);
Ptr<ObjectCollection> ObjectColl = adsk::core::ObjectCollection::create();
if(!ObjectColl)
return false;
if(!ObjectColl)
return false;
ObjectColl->add(MyLines[0]);
ObjectColl->add(MyLines[1]);
ObjectColl->add(arc0);
ObjectColl->add(circle0);
ObjectColl->add(MyLines[1]);
ObjectColl->add(arc0);
ObjectColl->add(circle0);
msg = " After ObjectColl->add(); ";
ui->messageBox(msg);
ui->messageBox(msg);
// Create a transform to do move
Ptr<Vector3D> vector = adsk::core::Vector3D::create(2.0, 3.0, 0.0);
if(!vector)
return false;
Ptr<Vector3D> vector = adsk::core::Vector3D::create(2.0, 3.0, 0.0);
if(!vector)
return false;
Ptr<Matrix3D> transform = adsk::core::Matrix3D::create();
if(!transform)
return false;
if(!transform)
return false;
transform->translation(vector);
Ptr<Features> features = rootComp->features();
if(!features)
return false;
// Create a move feature
Ptr<MoveFeatures> moveFeats = features->moveFeatures();
if(!moveFeats)
return false;
Ptr<MoveFeatureInput> moveFeatureInput = moveFeats->createInput(ObjectColl, transform);
if(!moveFeatureInput)
return false;
if(!moveFeatureInput)
return false;
msg = " After moveFeatureInput ";
ui->messageBox(msg);
ui->messageBox(msg);
Ptr<MoveFeature> moveFeature = moveFeats->add(moveFeatureInput);
if(!moveFeature)
return false;
if(!moveFeature)
return false;
msg = " After moveFeature ";
ui->messageBox(msg);
ui->messageBox(msg);
return true;
}
Solved! Go to Solution.