Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

More performant method of oView.SetVisibility?

6 REPLIES 6
Reply
Message 1 of 7
CadUser46
583 Views, 6 Replies

More performant method of oView.SetVisibility?

I'm reviewing an old but commonly used macro to see if i can make it more performant.  With part priority active it allows a user select a component in a drawing view, then it turns off the visibility of every other component, leaving just the one they clicked on. 

 

For small assemblies it's fine but as part count increases so does the time it takes to process.  It's significantly more than doing control/shift select's in the browser, right click>visibility=false.

 

Rather than setting visibility on each iteration of a loop, i tried creating an array of oRefAssy.ComponentDefinition.Occurrences(i) but it always result in 'nothing'.  I'm not sure why and i didn't get as far as trying to pass this in just to see if it would work.

ie Dim oOccs() As ComponentOccurrence

 

 

In any case, is there a better way to turn off the visibility of multiple child components in a drawing view?  Quantities can be >100s, screenupdating is always false.


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
6 REPLIES 6
Message 2 of 7
garrettfulghum
in reply to: CadUser46

Okay I feel your pain here,

Many times when I find myself needing to change the visibility of the same parts in my assembly I just stick all the parts in a browser folder and change the folders visibility manually. (It does it like a group)

 

However, if in your case you want to use Ilogic and the part names are all the same, the best way to loop it in my eyes is to use the:

'foreach occurrence in oAsmDoc.ComponentDefinition.Occurrences'.

Then to check to see if the occurrence.name is the part you want to change the visibility.

 

You might even want to consider creating LOD's to support that many parts to speed up Inventor if thats an option you can do. Let me know if this helps!

Message 3 of 7
CadUser46
in reply to: garrettfulghum

Garret, sorry i'm not getting notifications for replies. 

I am already doing as you suggest in using foreach oAsmDoc.ComponentDefinition.Occurrences(i)' but like i say the performance is not great once the count increases.  By comparison i can ctrl/shift select the same components in the browser and it turns off visibility in say 1 second vs 30s+ using the foreach method.

 

I thought there may be a way to add all the components i want turned off into a selectset or something, then apply the visibility only once, rather than in a loop, but the .setvisibility method does not allow this.  I also thought in the browser it's more akin to using ReferenceDocumentDescriptor than ComponentOccurences.


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
Message 4 of 7
LukeDavenport
in reply to: CadUser46

Hi CadUser46

The fastest method I found was:

DesignViewRepresentation.SetVisibilityOfOccurrences( Occurrences As ObjectCollection, Visible As Boolean)

 

You just need to create an ObjectCollection and add all your occurrences, and you can probably just use 

 

ThisApplication.ActiveEditDocument.ComponentDefinition.RepresentationsManager.ActiveDesignViewRepresentation

As the DesignViewRepresentation object (View Rep) if you don't already have it.

Hope this helps,

Luke

 

Message 5 of 7

Oh I just noticed you're talking about Drawing Views not Assembly visibilities. Hmmm. 

Well you could try using the method I posted to create / update a view rep in the assembly the drawing view references, and then use DrawingView.ActiveDesignViewRepresentation to apply it. That would probably be a lot faster than the SetVisibility method.

 

 

Message 6 of 7
CadUser46
in reply to: LukeDavenport

Luke, this is the kind of thing i had in my mind, creating a collection of occurrences in the drawing view then setting them all at once.  I guess i could do some testing to see if it's quicker to set a transient view rep in the model, place the drawing view, make sure it's not associative, then delete the view rep from the model.  I was hoping to avoid dirtying the model but the idea may have some mileage.


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
Message 7 of 7
garrettfulghum
in reply to: CadUser46

The easy thing to do if you change the visibility multiple times during an active open inventor session is to run your rule, grab all the Occurrences and have those links stored in memory until the program is ran again.

 

I do a ton of external apps connecting to inventor and Its easy to store that group in a component occurrence collection then re-run the rule for only that smaller occurrence group so i don't have to re-scan the entire assembly for those same documents. However, if the program or inventor is closed, those links are lost.

 

Im afraid even if you did group them in a rule/Group, Inventor will still have to cycle every part in the assembly behind the scenes to change the visibility. In my eyes, the only way speed up the process is to limit the group that is being scanned from the entire assembly, to a smaller group that has already been collected from a previous run. Or maybe a Design View Rep if thats possible.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report