I want a unique ID of Body for tracking. I have used solidworks API GetPersistReference3() but it gives null.
Is there any other way to get unique ID of body?
Check methods here: Tracking Objects
Can you share your code for getting persist ids? It shouldn't be null unless your are in assembly or drawing and not using correct context.
CComPtr<ICurve> lineCrv = NULL;modeler->ICreateLine(startPoint, dir, &lineCrv );
CComPtr<ICurve> trimmedLineCrv = NULL;lineCrv ->CreateTrimmedCurve2(startPoint, startPoint, startPoint, endPoint, endPoint, endPoint, &trimmedLineCrv );
CComPtr<IBody2> swBody = NULL;trimmedLineCrv ->CreateWireBody(&swBody );
VARIANT persistID;docExt->GetPersistReference3(swBody .p, &persistID);
I am using part document.
This is a temp body so it cannot have persist id by definition as it doesn't exist in the context of the model within the vurrent session only until its pointer is released. Use pointer to the body instead. If you want to store the body geometry and retrieve it in new session you can serialize it to stream: Storing and restoring temp body in 3rd party storage using SOLIDWORKS API
Thanks for the information. I have tried it. Code is as follow.
CComPtr<IUnknown> unknown;activeModelDoc->IGet3rdPartyStorage(L"BODY_STREAM_NAME", VARIANT_TRUE, &unknown);
The problem is the stream "unknown" returned by this function is NULL??
You can only save body to storage within the save to storage notification. Read this blog post: Detailed guide on storing the data in 3rd Party Storage And Store
Retrieving data ...