What is the provided guid?


#1

Hi,

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,
Cyril


#2

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


#3

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

// guid
SUStringRef guidSKP = SU_INVALID;
SUStringCreate(&guidSKP);
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;
  }
  SUStringRelease(&guidSKP);
}

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.


#4

Oh - you mean they are different in different models?


#5

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


#6

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.


#7

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 ?


#8

Yep, that’s correct.


#9

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 ?


#10

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


#11

Thank you Bugra.
Regards,
Cyril.