Add occurrence gets wrong part

Valued Contributor
Valued Contributor

 The following code is misbehaving.  Specifically, I'm passing a full path ("c:\\1\\products\\....") as fileInfo, but after adding, occurrence.PartFileName has a completely different (but existing) path.  It varies from run to run too, despite the input being the same.  It's like SolidEdge is searching the neighorhood of my file and picking a random file it likes because it has the same filename.

 

Only the trailing file name is correct.

 

  public void AddWithMatrix(FileInfo fileInfo, Mat4x4 matrix)
{ bool visible=true; SolidEdgeAssembly.Occurrences occurrences = mOccurrences;
SolidEdgeAssembly.Occurrence occurrence = null;
if (fileInfo.Exists) { double[] d = matrix.GetData(); try { occurrence = occurrences.AddWithMatrix( OccurrenceFileName: fileInfo.FullName, Matrix: d); occurrence.Visible = visible; } catch (System.Runtime.InteropServices.COMException ex) { Console.WriteLine(ex.Message); return null; } Debug.WriteLine(occurrence.PartFileName); } }

 

 

2 REPLIES

Re: Add occurrence gets wrong part

Phenom
Phenom

The clue I think is

"searching the neighorhood of my file and picking a random file it likes because it has the same filename"

 

Solid Edge will always get the file from the same folder as the assembly.

If you want the one from a different folder it cannot exist in the assembly folder.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.

Re: Add occurrence gets wrong part

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Alan,

 

beachcomber is correct. Below is a screenshot of doing this process manually. Solid Edge will warn you on save.

 

DuplicatePartDocument.png

Jason Newell
Applications Architect
www.jasonnewell.net