Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
coincidentConstraint Does Not Work,
Hi,
the following C++ Code to Test addCoincident(point, entity) Does Not Work.
I will appreciate if someone can make it work.
Regards,
Thurai
////////////////////////////////////////////////////////////
extern "C" XI_EXPORT bool run(const char* context)
{
Ptr<Application> app = Application::get();
if (!app)
return false;
{
Ptr<Application> app = Application::get();
if (!app)
return false;
ui = app->userInterface();
if (!ui)
return false;
if (!ui)
return false;
Ptr<Documents> docs = app->documents();
if (!docs)
return false;
if (!docs)
return false;
// Create a document.
Ptr<Document> doc = docs->add(DocumentTypes::FusionDesignDocumentType);
if (!doc)
return false;
Ptr<Document> doc = docs->add(DocumentTypes::FusionDesignDocumentType);
if (!doc)
return false;
Ptr<Design> design = app->activeProduct();
if (!design)
return false;
if (!design)
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 sketch
Ptr<Sketches> sketches = rootComp->sketches();
if (!sketches)
return false;
Ptr<Sketches> sketches = rootComp->sketches();
if (!sketches)
return false;
Ptr<Sketch> sketch = sketches->add(rootComp->xYConstructionPlane());
if (!sketch)
return false;
if (!sketch)
return false;
Ptr<SketchCurves> sketchCurves = sketch->sketchCurves();
if (!sketchCurves)
return false;
if (!sketchCurves)
return false;
// Draw some circles.
Ptr<SketchCircles> sketchCircles = sketchCurves->sketchCircles();
if (!sketchCircles)
return false;
Ptr<SketchCircles> sketchCircles = sketchCurves->sketchCircles();
if (!sketchCircles)
return false;
Ptr<SketchLines> sketchLines = sketchCurves->sketchLines();
if(!sketchLines)
return false;
if(!sketchLines)
return false;
// Get sketch texts
Ptr<SketchPoints> sketchPoints = sketch->sketchPoints();
if (!sketchPoints)
return false;
Ptr<SketchPoints> sketchPoints = sketch->sketchPoints();
if (!sketchPoints)
return false;
/* Add Coincident Constraint */
// returnValue = geometricConstraints_var->addCoincident(point, entity);
// Use the returned lines to add some constraints.
Ptr<GeometricConstraints> constraints = sketch->geometricConstraints();
if(!constraints)
return false;
Ptr<GeometricConstraints> constraints = sketch->geometricConstraints();
if(!constraints)
return false;
Ptr<Point3D> point3D = Point3D::create(0, 0, 0);
Ptr<SketchPoint> sketchPoint = sketchPoints->add(point3D);
if (!sketchPoint)
return false;
if (!sketchPoint)
return false;
Ptr<Circle3D> circle3D = sketchCircles->addByCenterRadius(Point3D::create(8, 5, 0), 5);
if (!circle3D)
return false;
Ptr<Point3D> center = circle3D->center();
Ptr<SketchPoint> sketchPoint2 = sketchPoints->add(center);
if (!sketchPoint2)
return false;
if (!sketchPoint2)
return false;
Ptr<CoincidentConstraint> coincidentConstraint = constraints->addCoincident(sketchPoint2, sketchPoint);
if(!coincidentConstraint)
return false;
if(!coincidentConstraint)
return false;
return true;
}
#ifdef XI_WIN
#include <windows.h>
BOOL APIENTRY DllMain(HMODULE hmodule, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif // XI_WIN
////////////////////////////////////////////////////////////
Solved! Go to Solution.