A little C++ help, please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to write a script to access the various components of my model. I started off with the sample program that traverses the assembly, which works fine, but I'm trying to make some enhancements to it. And I'm confused. I'm sure it's something really simple, something that I'm not understanding about C++ programming, but I could really use some enlightenment. 🙂
I have a simple C++ method that takes a Component as an argument.
void MethodTakingComponentAsArgument(Ptr<Component> AComponent) { if (!AComponent) { ReportAnError... } ... }
In the main method I acquire the RootComponent, exactly as it's done in the original sample program, as follows...
Ptr<Product> product = app->activeProduct(); Ptr<Design> design = product; Ptr<Component> RootComponent = design->rootComponent();
Within that main method I can successfully access the fields of that RootComponent, such as...
ui->messageBox("The root component name is " + RootComponent->name());
but when I call my MethodTakingComponentAsArgument as ...
MethodTakingComponentAsArgument(RootComponent);
it doesn't get it. What gets passed in is a NULL value.
WHY? What am I doing wrong?