replacereference scenarios

Hi,

I am using Document Manager API to replace the references of Assembly/Part and Drawing documents. I am facing two situations as below, not sure if these are defects or ‘as designed’ behavior of the API. Would appreciate if someone could throw light on these and let me know if I am doing it incorrectly. Below scenarios are executed on a machine without SolidWorks installation, just DM API is installed.

Scenario 1:

Consider an assembly document ‘c:\Asmbly.sldasm’ which references two parts viz. ‘c:\part1.sldprt’ and ‘c:\part2.sldprt’.

Initially, when we query for references it gives the references correctly. Next, the reference location is updated as ‘c:\temp\part1.sldprt’ and ‘c:\temp\part2.sldprt’ using replacereference API. One thing observed with replacereference API is that the replaced references need to be resolved by SolidWorks application by opening the assembly and saving it. If the references are not resolved then we get the following

upon querying for references it gives the original locations i.e. ‘c:\part1.sldprt’ and ‘c:\part2.sldprt’. But there is another method ‘GetChangedReferences’ which returns the list of original references and corresponding list of replaced references which in this case is

OldReferences -> ‘c:\part1.sldprt’ and ‘c:\part2.sldprt’.

ReplacedReferences -> ‘c:\temp\part1.sldprt’ and ‘c:\temp\part2.sldprt’

Now without resolving these references (not opening and saving in SolidWorks) when I try to reset them to its original location, it seems that ‘replacereference’ api ignores the values since they are same. For an example when we try to replace the reference ‘c:\temp\part1.sldprt’ to ‘c:\part1.sldprt’ we need to pass as below

‘replacereference(“c:\part1.sldprt”, “c:\part1.sldprt”);’

Since old and replaced values are same, I think the api is ignoring.

Please let me know if this is defect/’as designed’. I would like the api to allow to reset the references to its original value.

Scenario 2:

Consider a drawing document ‘c:\Drw1.slddrw’ which references single part viz. ‘c:\part1.sldprt’

Initially, when we query for references it gives the references correctly. Next, the reference location is updated as ‘c: \part2.sldprt’ using replacereference API. Other thing observed with replacereference API is that the replaced references need NOT to be resolved by SolidWorks application for drawing document. Even if the references are not resolved then we get the following

upon querying for references it gives the updated location i.e. ‘c:\part2.sldprt.

When we use the method ‘GetChangedReferences’ which returns the list of original references and corresponding list of replaced references which in this case is

OldReferences -> ‘c:\part1.sldprt’

ReplacedReferences -> c:\part2.sldprt’

If we again change the reference to ‘c:\part3.sldprt’ and query the references then we get the updated references and GetChangedReferences returns the following

OldReferences -> ‘c:\part1.sldprt’ and c:\part2.sldprt’

ReplacedReferences -> c:\part2.sldprt’ and ‘c:\part3.sldprt’

As we can see there is a difference in the way replacereference is handled for drawing and assembly/part documents. Another observation is in case of drawings if the file of replaced reference exists then it behaves similar to scenario 1.

Would appreciate if someone could throw some light on the difference is the behavior and importantly how I can reset the reference to its original value.

Thanks

Dhananjay

SolidworksApi macros