Level of Details and Drawing Views

Level of Details and Drawing Views

Anonymous
Not applicable
2,300 Views
3 Replies
Message 1 of 4

Level of Details and Drawing Views

Anonymous
Not applicable

I'm having some difficutly figuring out how to handle the following situation.  I have a drawing that references an Weldment Assembly that contains multiple Levels of Detail.  I'm using C# to modify the base assembly via the API based on a seperate dialog box. 

 

The issue I'm running into is some views are not properly updating.  I'm getting partial view updates only whenever I perform either Inventor.DrawingDocument.Update() or Inventor.DrawingDocument.Update2(). I have performed updates on the base referenced assembly via Inventor.AssemblyDocument.Update2(true).  Specifically, welds are not updating in the views.

 

After the program has finished executing Inventor doesn't indicate that any of the sheets in the drawing file need to be updated (clicking on the "Update All Sheets" on the Manage Tool Bar has no effect and the "Update" icon next to it is greyed out indicating everything is fully updated).

 

This is probably the import part since the system is apparently trying to tell me what's going on, I'm just not smart enough to figure out exactly what it's trying to tell me.  If I right click on a view that isn't fully updated (view contains the inccorectly rendered welds) I receive the following message: 

 

  • Changes have been made to some assembly components sine this assembly was last saved which may affect component size and position.

If I select "yes" to update the assembly then receive the message:

 

  • Assembly (Level of Detail) cannot be saved because a different Level of Detail representation is being edited.  You must save (or close) that one before you can edit this one).

Now, I realize that when I right clicked on the view in the drawing I was attempting to open the assembly at the Level of Detail shown in that view (or I should say I'm basing this on the title of the Inventor window that contains the assembly).

 

Finally, if I actually Open the assembly in question in Inventor I get the notice about the file being out of date; however, when I select "yes" here everything immediately updates and all is well.  So this SHOULD lead me back to how I've opened the assembly for editing via the API as the source of the problem.  So, the command I'm issuing to open the assembly is

 

 

Drawing=(Inventor.DrawingDocument)OpenInventorFile(PATH + STEELDWG);

AssemblyA=(Inventor.AssemblyDocument)OpenInventorFile(Drawing.ReferencedFiles[2].FullDocumentName);

 

I've ensured that the ReferencedFiles[2] is pointing to the main assembly (not a Level of Detail).  I've guarenteed that I'm opening the correct assembly by utilizing the ReferencedFiles property of the Drawing; however, I suspect this is the wrong approach based on my problems.  The only other thing I can think of is to referece the file directly via a string, but wouldn't that should be the exact same as the above since Drawing.ReferencedFiles[2].FullDocumentName resolves to a string.

 

And at that point I'm stuck.  I'm not sure what else to check or try to solve the problem. Any Ideas?

 

Thanks, Alan

 

 

:

 

0 Likes
Accepted solutions (1)
2,301 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Ok, Had another Idea, I switched the order that the files were opened (assembly first then the drawing).  No luck.  However, looking going back to the assembly after the program has completed it's execution I can see that the assembly hasn't updated.  If I perform a manual update within inventor it updates (the assembly); however, switching back to the drawing and performing a manual update still doesn't update the views correctly. 

 

Alan

0 Likes
Message 3 of 4

alewer
Advocate
Advocate

Updating the drawing (through API or otherwise) does not update the referenced part/assembly documents.  I don't know details about what you're doing, but one way to update assemblies/parts shown in a drawing is to iterate through all drawings views and update referenced documents as required (I hope a VBA snippet is OK):

 

  Dim oDrawingDoc As Inventor.DrawingDocument
  Set oDrawingDoc = ThisApplication.ActiveDocument
  
  Dim oSheet As Inventor.Sheet
  Dim oView As Inventor.DrawingView
  Dim oDocument As Inventor.Document
  For Each oSheet In oDrawingDoc.Sheets
    For Each oView In oSheet.DrawingViews
  Set oDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument If oDocument.RequiresUpdate Then oDocument.Update2 (True) Next oView Next oSheet

 

This might be overkill (if all view are of same assembly for example, it is not necessary to iterate though all sheets/views), but again I don't know exactly what you are doing here.

 

This should solve your update problem.  As for saving with multiple levels of detail open, I haven't enough experience to be of help...

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Actually took that a step further and recursed through all the views on all the sheets as you suggested along with recursing through all the assemblies and parts referenced in said views.  No luck.  I know it has to do with the views that utilizes assemblies at various Levels of Details though.  Here's the code I used:

 

 

 

bool check = false;
do
{
foreach (Inventor.Sheet oSheet in Drawing.Sheets)
foreach (Inventor.DrawingView oView in sheet.DrawingViews)
try
{
check = AssemblyUpdateCheck( (Inventor.AssemblyDocument)oView.ReferencedDocumentDescriptor.ReferencedDocument );
}
catch
{
Inventor.PartDocument oPrt = (Inventor.PartDocument)oView.ReferencedDocumentDescriptor.ReferencedDocument;
if (oPrt.RequiresUpdate)
{
oPrt.Update2(true);
check = true;
}
}
} while (check);


bool AssemblyUpdateCheck(Inventor.AssemblyDocument oDoc)
{
bool check = false;

for (int ct = 1; ct <= oDoc.ReferencedDocuments.Count; ct++)
{
try
{
check = AssemblyUpdateCheck( (Inventor.AssemblyDocument)oDoc.ReferencedDocuments[ct] );
if (oDoc.RequiresUpdate)
{
oDoc.Update2(true);
check = true;
}
}
catch
{
if (oDoc.RequiresUpdate)
{
oDoc.Update2(true);
check = true;
}
}

}
return (check);
}

 

 

Like I said, I ended up taking this to an extreme.  The do...while loop will cause me to loop until I get one pass through all the DrawingViews and don't see any referenced documents that requiring an update.  Unfortunetly I get stuck in the do...while loop.  I ended up watching the value of oDoc.RequiresUpdate while stepping through the code and saw that for views that reference a Level of Detail that includes welds the oDoc.Update2(true) method wasn't causing a complete update for some reason (oDoc.RequiresUpdate wasn't set to false after the update2 method execution). 

 

I did discover a workaround though.  On all the views in question I noticed that I could switch those views to a Master Level of Detail in lieu of the Custom Level of Detail I had been using.  That one change allows everything to execute correctly.

 

I suspect there's a problem with how Inventor is updating the views when they are related to a document at a custom Level of Detail Or a combination of welds and a Custom Level of Detail.

 

Alan

0 Likes