> On Jun 16, 2021, at 4:43 PM, Pravin Bhat <
pro....@gmail.com> wrote:
>
> I'm using latest build of StepCode with ap242 schemas. My input STEP file defines an instance of LENGTH_UNIT. In my code the following returns a non-null pointer as expected:
> auto instance = stepInstances.GetApplication_instance("Length_unit");
It returns a SDAI_Application_instance*
> However, the following returns a null pointer:
> auto instance = dynamic_cast<SdaiLength_unit_ptr_c>(stepInstances.GetApplication_instance("Length_unit"));
>
> Question #1: What should type should I be using while casting this instance to gain access to the underlying length unit representation?
I’m not sure you can cast directly through from SDAI_Application_instance without some machinery in place, but you can introspect some things and construct off of it. We use a factory pattern in an AP203 converter, for example, where we map entities to Create() functions by name.
std::cout << "Name:" << sse->EntityName() << " ID:" << sse->STEPfile_id << std::endl;
if (sse->IsA(SCHEMA_NAMESPACE::e_length_unit)) ...
> To help find the instance type name I tried calling the function GetInstanceTypeName(...) defined in SDAI_DAObject_SDAI. However, it looks like this function in not implemented anywhere in the StepCode library, which causes the linker to raise "unresolved externals" error.
>
> Question #2: How do I access the GetInstanceTypeName(...) function in StepCode library?
That’s one of a handful of functions related to dynamic binding that are unimplemented. Relevant:
https://github.com/stepcode/stepcode/issues/387
Maybe someone can chime in with better knowledge, but I think they’re a dynamic binding interface from ISO 10303-23 (SDAI C++) that was stubbed in but remains incomplete. I’d have to dig up my copy of AP 22 and 23 to be certain.
The related code API wraps them in SDAI_CPP_LATE_BINDING, but GetInstanceTypeName() curiously has ifndef and that’s probably a typo in the header.
Cheers!
Sean