What is the provided guid?


What is exactly the guid that is available via SUComponentInstanceGetGuid or SUGroupGetGuid ?
I supposed that it gives a unique id that is the same for each loading occurence, but the provided guid seems to change if I load the same sketchup file again.

Thanks by advance,

Yes - instance GUID’s are persistent. Do you have an example code snippet and model?

I get the guid of an instance with that kind of code (os x cocoa) :

// guid
SUStringRef guidSKP = SU_INVALID;
SUComponentInstanceGetGuid(instanceSKP, &guidSKP);
if (!SUIsInvalid(guidSKP))
  size_t guidLength = 0;
  SUStringGetUTF16Length(guidSKP, &guidLength);
  if (guidLength)
    unichar* guidUTF16 = new unichar[guidLength + 1];
    SUStringGetUTF16(guidSKP, guidLength + 1, guidUTF16, &guidLength);
    guid = [NSString stringWithCharacters:guidUTF16 length:guidLength];
    delete [] guidUTF16;

And all the models of my testbed (such as this one https://3dwarehouse.sketchup.com/model.html?id=uee5ca521-6276-42ea-8fbd-22421b639c7e) give similar results : the guids are coherent, but change over time.

Oh - you mean they are different in different models?

No : different in the same model, with the same instance. But the problem occurs in all the files I used to test my loader.

Were the models saved in an older skp format (2013 or older)? These guids were introduced in SketchUp 2014 and older models do not have them. So, they have to be regenerated every time for an old model, until you save it in a newer format. It will be persistent after that.

OK thank you Bugra…

So if I want to know if a guid is a “true” one, what you implicitly suggest is that I need to trust only the ones that come from post-2013 models ?

Yep, that’s correct.

Could you tell me what are major and minor versions of the 2014 skp format, that introduces the guid ?

Is it the 14.0 version ?

Correct, 14.0 or above. You can query this via SUModelGetVersion.

Thank you Bugra.