The following code throws my exception when run from an Assembly.
Why does the ModelDoc2 not accept a persistreference3 that it just handed me?
const int PERSIST_REF_OBJ_OK = (int)swPersistReferencedObjectStates_e.swPersistReferencedObject_Ok;
public List
{
Debug.Print("SegmentsToPersistRefs called for list of " + segments.Count);
List
foreach (SketchSegment seg in segments)
{
object pid = mDoc.Extension.GetPersistReference3(seg);
if (pid == null)
{
throw new ApplicationException("SketchSegment GetPersistReference3 is null");
}
int errorCode;
object obj = mDoc.Extension.GetObjectByPersistReference3(pid, out errorCode);
if (errorCode != PERSIST_REF_OBJ_OK)
{
// *** ENDS UP HERE with errorCode = 1 == INVALID ***
throw new ApplicationException("Cannot get object from PersistRef3 we just got");
}
refs.Add(pid);
}
return refs;
}
SolidworksApi macros