Hi all,
I am using SketchUp C++ API to convert a sketchup model into a component definition and add it’s instance to another sketchup model. In the following code, i am adding catalogModeRef_k to ImportedSkpModel0.
Crash happens at SUModelSaveToFile(), with error “Exception thrown at 0x00007FFD2DEC3BE5 (SketchUpAPI.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF. occurred”
It doesn’t crash if i add only Materials and Component Definitions. Group definitions is causing the crash.
SUModelRef ImportedSkpModel0= SUModelCreateFromFile(.....); // this is working fine
SUModelRef catalogModeRef_k = SUModelCreateFromFile(.....); // this is working fine
if (SUIsValid(catalogModeRef_k))
{
//materials
size_t material_count = 0;
SUModelGetNumMaterials(catalogModeRef_k, &material_count);
size_t material_count_out = 0;
SUMaterialRef* materialRefs = new SUMaterialRef[material_count];
SUModelGetMaterials(catalogModeRef_k, material_count, materialRefs, &material_count_out);
SUResult addmaterials_result = SUModelAddMaterials(ImportedSkpModel0, material_count_out, materialRefs);
// component definition that define component instances but not groups
size_t compdef_count = 0;
SUModelGetNumComponentDefinitions(catalogModeRef_k, &compdef_count);
size_t compdef_count_out = 0;
SUComponentDefinitionRef* compdefs = new SUComponentDefinitionRef[compdef_count];
SUModelGetComponentDefinitions(catalogModeRef_k, compdef_count, compdefs, &compdef_count_out);
SUResult addcompdefs_result = SUModelAddComponentDefinitions(ImportedSkpModel0, compdef_count_out, compdefs);
// component definition that define groups -- adding group defs is causing crash when we save the skp model
size_t groupdef_count = 0;
SUModelGetNumGroupDefinitions(catalogModeRef_k, &groupdef_count);
size_t groupdef_count_out = 0;
SUComponentDefinitionRef* groupdefs = new SUComponentDefinitionRef[groupdef_count];
SUModelGetGroupDefinitions(catalogModeRef_k, groupdef_count, groupdefs, &groupdef_count_out);
SUResult addgroupdefs_result = SUModelAddComponentDefinitions(ImportedSkpModel0, groupdef_count_out, groupdefs);
}
SUResult SaveSkp_result = SU_ERROR_NONE;
if (SUIsValid(ImportedSkpModel0))
{
// save it as a new skp model
SaveSkp_result = SUModelSaveToFile(ImportedSkpModel0, SavePath); // CRASHING AT THIS POINT.
}