Message 1 of 2
API: build a joint using joint origins
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I have a component (a linkage, see attachment) with 2 joint origins. Here's what I'm trying to do: programmatically load 2 of those linkages and build a joint using the joint origins. Here's what I got so far:
app = Application::get();
if (!app)
return false;
ui = app->userInterface();
if (!ui)
return false;
Ptr<Design> design = app->activeProduct();
app->activeDocument()->saveAs("linkage test", app->data()->activeProject()->rootFolder(), "", "");
auto root = design->rootComponent();
auto project = app->data()->activeProject();
Ptr<Occurrence> occ1, occ2;
Ptr<DataFile> dataFile = nullptr;
for (auto file : project->rootFolder()->dataFiles()) {
if (file->name() == "linkage") {
dataFile = file;
break;
}
}
if (!dataFile)
ui->messageBox("file not found");
else {
occ1 = root->occurrences()->addByInsert(dataFile, Matrix3D::create(), false);
occ2 = root->occurrences()->addByInsert(dataFile, Matrix3D::create(), false);
//here's something wrong: g0 and g1 are null
auto g0 = JointGeometry::createByPoint(occ1->component()->jointOrigins()->item(0));
auto g1 = JointGeometry::createByPoint(occ2->component()->jointOrigins()->item(1));
auto joint = root->joints()->createInput(g0, g1);
root->joints()->add(joint);
}
I would appreciate any input, hint etc on this. Pseudocode or python is ok. Thank you.