Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assembly LoD keeps changing to Master after Drawing file is saved last.

26 REPLIES 26
Reply
Message 1 of 27
MegaJerk
2976 Views, 26 Replies

Assembly LoD keeps changing to Master after Drawing file is saved last.

(The following is in INV 2011)

 

I am having an issue with the Level of Detail representation of a drawing / assembly file that I’ve been working on.  Naturally I’ve set up a custom LoD (named Lenny for the purpose of this question), but at times my assembly goes back to Master LoD.

 

I have my Application options set up to open the last known LoD, and that works so long as I’m only opening one file at a time. The problem starts to happen I have both the Assembly and the Drawing file (that the Assembly is being represented on) open and I save the Drawing file last before closing out. Any time (after saving the drawing file last) that I open the Assembly file; it will automatically be set back to Master LoD.

 

Being that I’m still getting my chops with this program, I’m curious if this is the normal behavior of things. I assume that because it separates the drawing from the assembly documents (in Classes that is) when I save that drawing last, it sets the LoD last active name which will not work for the assembly due to the class difference. 

 

Is there a solution around this problem, or does anyone knows of a way to sort of easily set the LoD using a Vb rule?

 

1 million Thanks to you!



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
26 REPLIES 26
Message 2 of 27
SteveX82
in reply to: MegaJerk

I am having a similar issue with the assembly reverting to the Master LOD.

 

I created a configurator that combines many parts at an assembly level, and some of these parts may be suppressed depending on the desired configuration. This requires a custom Level Of Detail, which has worked without issue until it came time to make the dreaded assembly drawing.....

 

I've got 2 base views in my drawing, both of which are set to reference the custom Level Of Detail. However, every time I save the drawing and go to open the assembly, it chooses to default to the godforsaken "Master" LOD. I don't dare open both the drawing and the assembly at the same time, as this just results in a laundry list of error messages, refusals to save ANYTHING, and all sorts of other problems that make me want to throw a monitor through a window.

 

Is there a better way to handle part suppression that MegaJerk and I are missing, or are buggy LOD's something that users "just have to deal with" in Inventor?

Message 3 of 27
MegaJerk
in reply to: MegaJerk

I don’t know if it will help but since I last posted anything about LOD, I have managed to work up a solution that works for me! Because I only want to use one other LOD (that’s custom) it’s easy to use the following code to first check what the LOD is set to, and then change it over to my custom LOD if it isn’t already set. This is simply in an iLogic Rule on the Main Assembly:

 

'''We need to make sure the LOD is set correctly: 
'''
''' Side note
''' Public Enums for LevelOfDetailEnum 
''' kMasterLevelOfDetail = 56065
''' kAllComponentsSuppressedLevelOfDetail = 56066  
''' kAllPartsSuppressedLevelOfDetail = 56067
''' kAllContentSuppressedLevelOfDetail = 56068  
''' kSandboxLevelOfDetail = 56069
''' kTransientLevelOfDetail = 56070  
''' kSubstituteLevelOfDetail = 56071
''' kCustomLevelOfDetail = 56072  
''' kLastActiveLevelOfDetail = 56073
''' End Enum

Dim doc as AssemblyDocument = ThisDoc.Document  
If doc.ComponentDefinition.RepresentationsManager.ActiveLevelOfDetailRepresentation.LevelOfDetail <> 56072 Then 
Dim oLOD As LevelOfDetailRepresentation
Dim oAsmCompDef As ComponentDefinition
oAsmCompDef = doc.ComponentDefinition
oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Lenny")
oLOD.Activate(True)
End If

 

Also, because the above code runs every time I save the Assembly, it tends to play a lot nicer with the drawing than what it ever had before. I can now at least have both open at the same time, but I do tend to try and not bounce back and forth between them too much as I’m still not 100% sure that it won’t break suddenly for no reason. So far though, months and months of no breaking LOD madness!

 

Now, because you’re using multiple LODs, it makes me curious if looking at the kLastActiveLevelOfDetail  (56073) wouldn’t be the way to go. Because I believe you can set up a similar option in Inventor (to always use the last used LOD), and because that option is sometimes totally ignored (possibly because someone else might have opened the file or because of magic), you could certainly go about it in a more offhanded way.

Perhaps if you set up a multivalue parameter that would change the LOD based on which value you had selected, and a check at the opening of the Assembly to make sure that the LOD is set to match that selection.



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 4 of 27
mrattray
in reply to: MegaJerk

Thanks for this, I've been punching my keyboard out of frustration all week.

Mike (not Matt) Rattray

Message 5 of 27
MegaJerk
in reply to: mrattray

Tell us how it works, and what your final solution is, the more information everyone has, the better! 

 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 6 of 27
mrattray
in reply to: MegaJerk

My assembly started throwing errors for no apparent reason. (before I added your code). I then added your code hoping I was that lucky and I'm still getting the following two errors as well as some windows "fatal exception" crap that it wont let me copy/paste.

*sigh* At least it's Friday...

 

Error in rule: Engine, in document: GrateMagSquare-RulesBased.iam

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

Error in rule: Engine, in document: GrateMagSquare-RulesBased.iam (USE THIS ONE!)

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

Mike (not Matt) Rattray

Message 7 of 27
MegaJerk
in reply to: mrattray

If you’re using Inventor 2011, and the assembly isn’t too topsecret, I wouldn’t mind trying to open it up over here on my work station to see if I can’t figure out the problem. Throw it up on here if you can, or you can email it to me.

 

 Unspecified errors are always the best (L)!



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 8 of 27
mrattray
in reply to: MegaJerk

I'm on 2012, but I'll post it anyways.

Mike (not Matt) Rattray

Message 9 of 27
johnsonshiue
in reply to: MegaJerk

Hi! If I understand the workflow correctly, I think I might have an explanation of this behavior. But, I need your confirmation first. When you create the drawing views, was the last view you created referencing LOD:Master in the assembly? When you save the drawing, did you see the assembly got listed in the Save dialog and Save action set to Yes?

I suspect there are views in the drawing pointing to LOD:Master. As a result, the Master becomes the last active LOD in the assembly. Next time when you open it, Master will be come the default. Does it make sense?

Thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 10 of 27
mrattray
in reply to: johnsonshiue

Thanks for the suggestion, it would make sense, except all the views reference the same custom LOD.  There are details in the same drawing file on different sheets that reference their own master LOD.  They do not have rules in their part files but their paramters are driven by rules at the assembly level. I can't imagine that would be the cause of the problem, do you?

Mike (not Matt) Rattray

Message 11 of 27
SteveX82
in reply to: mrattray

Do you have a parts list / BOM on your assembly drawing? If so, I suspect that's the "cause" of the LOD tug-of-war.

 

It seems that the parts list references the Master LOD and must "activate" it to get an updated list. Combine that with the requirement to use a custom LOD with iLogic, and you've got a recipe for trouble.

Message 12 of 27
mrattray
in reply to: SteveX82

After some experimentation I have confirmed that the drawing is what is setting my LOD back to master.  Is there a way to default the save settings to not save the assembly when I save the drawing? This would of course need to be a setting unique to this drawing, as I don't want to break associativity with my other drawings and models.

The other course of action would be to somehow set the parts list to look at the custom LOD. I'm not sure how to set that, either.

Mike (not Matt) Rattray

Message 13 of 27
Saad.
in reply to: johnsonshiue

Hello,

Hope you must be fine, I've just read your post, I've same problem with assembly, its keeps on changing to Master LOD from custom after drawing, I've just one custom LOD in assembly and drawing containing all views referencing to this custom LOD.

 

you said, "did you see the assembly got listed in the Save dialog and Save action set to Yes?"

 

Yes,  I got listed assembly every time  in Save dialog and Save action set to Yes

 

when I set 'save action' to 'NO', then assembly opens with custom LOD (my requirement)

when I set 'save action' to 'YES', then assembly opens with Master LOD

 

Can it be possible to set 'save action' of assembly to 'NO' permenently in drawing mode, or any other way to stop this changing of LOD

 

Thanks

 

 

Message 14 of 27
mrattray
in reply to: Saad.

I've only found two work arounds to this.

 

1) It's the parts list that's the main culprit. You can delete or avoid creating the parts list until your design is complete, or you can move it off onto another sheet. If you don't update the parts list when you go ginto the drawing, then you wont have a poblem.

2) I wrote an iLogic macro that reverts all assemblies (including subs) to an explicitly named LOD. There's an alternate version written by MegaJerk that converts to the last active custom LOD as well, but it doesn't look at sub asemblies. If your interested in mine I'll post it. You'll have to search the forum if you want to try MegaJerk's. Niether method will prevent your assemblies from reverting, but it will reduce the headache.

 

If your problem is the same as mine was, that is your rules messing up, then the macro is the way to go.

Mike (not Matt) Rattray

Message 15 of 27
Bezdar
in reply to: mrattray

Hi, have you noticed Inventor requires to save all components after LOD was changed manually? Your macro works for me If I save everything after macro finished.

I had/have a problem  with LOD for components, which became active after supression.

Thanks for macro.

Message 16 of 27
Bezdar
in reply to: Bezdar

Maybe LOD return to Master if you save a drawing while it is still under construction? Some views  require more time to finish.Until they are finished a green corners are displayed around view.

Message 17 of 27
Bezdar
in reply to: SteveX82

Try to start with Parts List building only after    DrawingView.IsUpdateComplete

Message 18 of 27
Arrush80_
in reply to: mrattray

Would you be willing to share your macro? I'm ready to try anything at this point.

 

thanks

Message 19 of 27
mrattray
in reply to: Arrush80_

Here it is: (I owe credit to MegaJerk and Curtis W.)

 

Imports Inventor.LevelOfDetailEnum
Imports Inventor.BOMStructureEnum

Sub Main

iLogicVb.UpdateWhenDone = True

Dim doc As AssemblyDocument
Dim oLOD As LevelOfDetailRepresentation
Dim oAsmCompDef As ComponentDefinition
Dim oComp As ComponentOccurrence
Dim oComps As ComponentOccurrences
Dim oCompCompDef As AssemblyComponentDefinition
Dim LODname As String

'Set LODname to whatever you like your LOD's to be named as.
LODname = "Custom"

doc = ThisDoc.Document
If doc.ComponentDefinition.RepresentationsManager.ActiveLevelOfDetailRepresentation.LevelOfDetail <> kCustomLevelOfDetail Then 
	oAsmCompDef = doc.ComponentDefinition
	Try
		'Try to set our assemblies active LOD to the above specified.
		oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item(LODname)
		oLOD.Activate(True)
	Catch
		Try
			'It didn't work so we need to create a new one and then set it.
			oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add(LODname)
			oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item(LODname)
			oLOD.Activate(True)
		Catch
			MsgBox("LOD error 1")
			Exit Sub
		End Try
	End Try
End If

'Iterate through all of the component's in the assembly.
oComps = doc.ComponentDefinition.Occurrences
For Each oComp In oComps
	'Make sure the component isn't a weld bead.
	If Left(oComp.Name, 10) <> "_Weldbead:"
		'Make sure the component isn't suppressed to avoid the resulting error.
		If oComp.Suppressed = False Then
			'Make sure the component isn't a virtual component to avoid the resulting error.
			If Not TypeOf oComp.Definition Is VirtualComponentDefinition Then
				'Make sure the component is an assembly.
				If oComp.ReferencedDocumentDescriptor.ReferencedDocumentType = kAssemblyDocumentObject Then
					'Check if the active LOD is already correct or not.
					If oComp.ActiveLevelOfDetailRepresentation <> LODname Then 
						Try
							'Try to set our copmponent's active LOD to the above specified.
							oComp.SetLevelOfDetailRepresentation(LODname, True)
						Catch
							'It didn't work so we need to create a new one and then set it.
							Try
								oCompCompDef = oComp.Definition
								oCompCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add(LODname)
								oComp.SetLevelOfDetailRepresentation(LODname, True)
							Catch
								MsgBox("LOD error 2")
								Exit Sub
							End Try
						End Try
					End If
				End If
			End If
		End If
	End If
Next

End Sub

 

I don't use this anymore as I've abandoned LOD's and Compnent.IsActive() and never looked back. Instead, I wrote a sub that automatically sets visibility and BOM structure to emulate the same function without any of the headaches. I highly recomend you try this method! Here's the sub and an example of how to call it:

 

Sub Main()

bomRef("my component:1",False)

End Sub

Sub bomRef (ByVal compName As String, ByVal compOn As Boolean)

Dim oAsmDoc As AssemblyDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Dim oCompOcc As ComponentOccurrence
Dim bomStruct As Long

oAsmDoc = ThisDoc.Document
oAsmCompDef = oAsmDoc.ComponentDefinition
oCompOcc = oAsmCompDef.Occurrences.ItemByName(compName)

If compOn = True Then
	bomStruct = 51969 'kDefault
Else
	bomStruct = 51972 'kReference
End If

oCompOcc.BOMStructure = bomStruct

Component.Visible(compName) = compOn

End Sub

 

 

Mike (not Matt) Rattray

Message 20 of 27
Arrush80_
in reply to: mrattray

Thank you very much for this! I'm a pretty basic user of iLogic so I hope you dont mind a few more questions.

 

For the LoD code, I understand it will revert the current assembly, and sub assemblies to the chosen LoD. What method did you use to run the code? The reason I ask, I found this one liner "ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Custom_LoD").Activate" which I was thinking could be triggered on opening of the file and should accomplish the same with a lot less code.

 

Second, I am really interested in using your visibility code. Would you be able to tell me how it is used? Can I still control the visibility with iLogic (similar to component is active) and if so what is the code for that? Does changing the visibility require a custom view representation and if so do you still run in to the issues where perhaps the visibility resets to master?

 

Thank you.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report