- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Loft with openprofile using C++ with the following code does not work.
Please correct it, try it in your PC and let me know.
Regards,
Thurai
#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>
using namespace adsk::core;
using namespace adsk::fusion;
using namespace adsk::cam;
using namespace std;
using namespace adsk::fusion;
using namespace adsk::cam;
using namespace std;
Ptr<Application> app;
Ptr<UserInterface> ui;
Ptr<UserInterface> ui;
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;
Ptr<Component> rootComp = design->rootComponent();
if (!rootComp)
return false;
if (!rootComp)
return false;
// Create profile 1
Ptr<Sketches> sketches = rootComp->sketches();
if (!sketches)
return false;
Ptr<Sketches> sketches = rootComp->sketches();
if (!sketches)
return false;
Ptr<Sketch> sketch0 = sketches->add(rootComp->yZConstructionPlane());
if (!sketch0)
return false;
if (!sketch0)
return false;
Ptr<SketchCurves> sketchCurves = sketch0->sketchCurves();
if (!sketchCurves)
return false;
Ptr<SketchLines> sketchLines = sketchCurves->sketchLines();
if (!sketchLines)
return false;
if (!sketchLines)
return false;
Ptr<Point3D> Point00 = adsk::core::Point3D::create(0, 0, 0);
if (!Point00)
return false;
Ptr<Point3D> Point01 = adsk::core::Point3D::create(0, 0, 10);
if (!Point01)
return false;
if (!Point01)
return false;
Ptr<Point3D> Point10 = adsk::core::Point3D::create(0, 10, 0);
if (!Point10)
return false;
Ptr<Point3D> Point11 = adsk::core::Point3D::create(0, 10, 20);
if (!Point11)
return false;
Ptr<SketchLine> Line0 = sketchLines->addByTwoPoints(Point00, Point01);
Ptr<SketchLine> Line1 = sketchLines->addByTwoPoints(Point10, Point11);
Ptr<Profiles> profiles = sketch0->profiles();
if (!profiles)
return false;
Ptr<Profile> profile0 = rootComp->createOpenProfile(Line0);
if (!profile0)
return false;
ui->messageBox("After profile0");
Ptr<Profile> profile1 = rootComp->createOpenProfile(Line1);
if (!profile1)
return false;
ui->messageBox("After profile1");
if (!profile1)
return false;
ui->messageBox("After profile1");
// Create loft feature input
Ptr<Features> feats = rootComp->features();
if (!feats)
return false;
Ptr<Features> feats = rootComp->features();
if (!feats)
return false;
Ptr<LoftFeatures> loftFeats = feats->loftFeatures();
if (!loftFeats)
return false;
if (!loftFeats)
return false;
Ptr<LoftFeatureInput> loftInput = loftFeats->createInput(adsk::fusion::FeatureOperations::NewBodyFeatureOperation);
if (!loftInput)
return false;
if (!loftInput)
return false;
Ptr<LoftSections> loftSectionsObj = loftInput->loftSections();
if (!loftSectionsObj)
return false;
if (!loftSectionsObj)
return false;
Ptr<LoftSection> loftSection0 = loftSectionsObj->add(profile0);
if (!loftSection0)
return false;
if (!loftSection0)
return false;
Ptr<LoftSection> loftSection1 = loftSectionsObj->add(profile1);
if (!loftSection1)
return false;
if (!loftSection1)
return false;
loftInput->isSolid(false);
// Create loft feature
Ptr<LoftFeature> loftFeature = loftFeats->add(loftInput);
if (!loftFeature)
return false;
Ptr<LoftFeature> loftFeature = loftFeats->add(loftInput);
if (!loftFeature)
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.