Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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: 

Suppress Component in multiple Level of Details

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
pierre.masson
5126 Views, 15 Replies

Suppress Component in multiple Level of Details

You are using an assembly with many LODs. Each time you place a component in your assembly , that one will be active in all level of Details.

For some configurations, you would like one component to be active in only one LOD.

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
15 REPLIES 15
Message 2 of 16

With the code below, you can select one part, and then select on LOD. The code will run through all LODs and suppress the part in all LODs except the one you selected, and the standard ones and Substitutes of course.

So you part will only be active in one of your User defined LOD.

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
Message 3 of 16

Public Sub SuppressComponentreps()
' Set reference to active document.
' This assumes the active document is an assembly
Dim oDoc As Inventor.AssemblyDocument
Dim selset As SelectSet
Dim PartList As New Collection
Dim LODList As New Collection
Dim compOcc As ComponentOccurrence
Dim oCompDef As Inventor.ComponentDefinition
Dim lodrep As LevelOfDetailRepresentation
Dim lod As LevelOfDetailRepresentation


Set oDoc = ThisApplication.ActiveDocument
Set oCompDef = oDoc.ComponentDefinition

oDoc.SelectSet.Clear

MsgBox ("Select a Part or a Subassembly")
Do While oDoc.SelectSet.Count = 0
    DoEvents    ' Yield to other processes.
Loop

Set selset = oDoc.SelectSet
Dim obj As Object
For Each obj In selset
    If TypeOf obj Is ComponentOccurrence Then
                PartList.Add obj
    End If
Next

oDoc.SelectSet.Clear

MsgBox ("Select the Level of Detail where the component will be active." & Chr(13) & "Master, Components Suppressed, Parts Suppressed and Concent center suppressed won't be treated" & Chr(13) & "Substitutes cannot be treated")
      Do While oDoc.SelectSet.Count = 0
        DoEvents    ' Yield to other processes.
    Loop


Dim selSetLOD As SelectSet
Set selSetLOD = oDoc.SelectSet
Dim objLOD As Object
For Each objLOD In selSetLOD
            LODList.Add objLOD
Next

Set compOcc = PartList.Item(1)
Set lod = LODList.Item(1)
      
For Each lodrep In oCompDef.RepresentationsManager.LevelOfDetailRepresentations
    If (lodrep.Name = lod.Name) And (lodrep.LevelOfDetail <> kSubstituteLevelOfDetail) Then
        lodrep.Activate
        If compOcc.Suppressed = True Then
            compOcc.Unsuppress
        End If
        oDoc.Update
        oDoc.Save
       
    End If
   
  If (lodrep.LevelOfDetail <> kMasterLevelOfDetail) And (lodrep.LevelOfDetail <> kAllComponentsSuppressedLevelOfDetail) And _
                             (lodrep.LevelOfDetail <> kAllPartsSuppressedLevelOfDetail) And (lodrep.LevelOfDetail <> kAllContentSuppressedLevelOfDetail) And (lodrep.Name <> lod.Name) And (lodrep.LevelOfDetail <> kSubstituteLevelOfDetail) Then
                            lodrep.Activate
                            compOcc.Suppress
                            oDoc.Update
                            oDoc.Save
    End If
Next

oDoc.Update

End Sub

 

 

 

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
Message 4 of 16

This API needs to be more tested, with big assemblies. If you like it, please Kudo.

If you find improvements or other solutions, please post.

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
Message 5 of 16
Anonymous
in reply to: pierre.masson

This looks like just the tweak we need, we are using LODs on huge assemblies, so big that none of our computers can open the master LOD and when we put aan assembly in it insists on going in to all other LODs at the master level which often means we can't then open them.

 

I know this is probably a bit obvious but how do I use this?

 

Message 6 of 16
Anonymous
in reply to: Anonymous

I forgot to mention we are using Inventor 2011 under Win7 64
Message 7 of 16
pierre.masson
in reply to: Anonymous

Paste the code i wrote above in the VBA Editor of Inventor and run it.

 

It will ask you to select one part, and then one LOD.

 

The code will run through all LODs and suppress the part in all LODs except the one you selected, and the standard ones and Substitutes of course.

So you part will only be active in one of your User defined LOD.

 

I tested it in 2012, but it should be working fine in 2011.

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
Message 8 of 16
Anonymous
in reply to: pierre.masson

Well it works on a simple assembly. Unfortunately it seems to be working by opening the LODs which has hung up my computer seriously when trying it on one of the assemblies that I am having problems with. Do give an Idea of the scale of problem we have, the master for this assembly has somewhere around 165000 parts. This seems to be well beyond IVs capability. I'm obviously not an Autodesk developer but I would have thought that the LODs were controlled by a table of sorts which should be quicker to edit than by opening the whole assembly.
Message 9 of 16
pierre.masson
in reply to: Anonymous

Yes, you need to activate a LOD to make some changes in it. Even via API.

 

If I understand your problem well :

  1. When opening the assembly, you can select options and open with the LOD All parts suppressed
  2. In the assembly Right CLick on the LOD and select copy, it will copy this LOD, and then you can activate manually the parts you need
  3. Right click on Level of Detail, new substitute, shrinkwrap and it will derive your entire assembly into one single part, which is much more lighter to work with.

 

Thanks.

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
Message 10 of 16
Anonymous
in reply to: pierre.masson

Unfortunately that isn't a solution as most of the stuff that is in the model needs to be live as it is all being worked on and is all interactive. It is something that possibly ought to be addressed for a future release as in the current form, we are having to re-create LODs every time a big model is added to the assembly because irrespective of what LOD you put a sub-assembly in, it is seen as a master in all other LODs of the top level assembly. Either that or make IV capable of handling large assemblies...
Message 11 of 16
pierre.masson
in reply to: Anonymous

Hi

 

That's true. I understand your issue now. The macro could solve this, but it might take a lot of time if have really huge assemblies.

You can probably try to lower the Display and Hardware Settings in Application options (just for Running the code).

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
Message 12 of 16
pierre.masson
in reply to: Anonymous

 

Please submit us your feedback here, it is an interesting improvement request :

http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1109794

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
Message 13 of 16
floccipier
in reply to: pierre.masson

It shows following error

Compiler error:

Syntax error

 

with following line of code shown in red

 

For Each lodrep In oCompDef.RepresentationsManager.LevelOfDetailRepre?sentations

 

Please suggest what to do.

 

Regards,

Sajid Mahmood

Message 14 of 16
pierre.masson
in reply to: floccipier

Hello

 

You pasted this text :

 

For Each lodrep In oCompDef.RepresentationsManager.LevelOfDetailRepre​?sentations

 

There is a question mark in Repre​?sentations. If this is also in your code, then you need to remove it.

Pierre Masson Product Support Specialist PS MFG EMEA Autodesk, Inc.
Message 15 of 16
Anonymous
in reply to: pierre.masson

Hi,

 

I realise that the original code you placed on the forum was in 2012...but any chance you have an updated code that works on 2017?

Message 16 of 16
sam
Advocate
in reply to: pierre.masson

Thank you so much. This is brilliant. 

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

Post to forums  

Autodesk Design & Make Report