Advanced Feature Validation option

Advanced Feature Validation option

JohnKHouston
Advocate Advocate
870 Views
9 Replies
Message 1 of 10

Advanced Feature Validation option

JohnKHouston
Advocate
Advocate

Hello all,

 

I'd like to request some help and I was directed here to see if someone would be able to create some code that would turn off the "Advanded Feature Validation" option. I've attached a screenshot to illustrate.

 

For whatever reason, this option is selected in all of our assembly files and it slows down the performace of those assemblies. I've manually been deselecting the option on every assembly that I've been working on but it's a tedious task that I would love to automate.

 

Ultimately it would be great to 'flip the switch' globally but whatever anyone can suggest would be greatly appreciated!

 

Thanks in advance for any help/ suggestions!

 

Best regards,

John

 

 

advanced_feature_validation_option.jpg

0 Likes
Accepted solutions (3)
871 Views
9 Replies
Replies (9)
Message 2 of 10

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

Hi John,

 

You could add a code like this to the VBA module:

Sub SwitchOffAFV()
  Dim d As Document
  Set d = ThisApplication.ActiveDocument
  
  If d.ModelingSettings.AdvancedFeatureValidation Then
    d.ModelingSettings.AdvancedFeatureValidation = False
    d.Rebuild
  End If
End Sub

 

.. and a button for that command could be added onto the Ribbon from "Customize User Commands..."

 

afv.png

 

That could save you a couple of clicks.

 

It could also be enhanced so that it's done for everyone document you open, or there could be a function that goes throgh all files in a specific folder and changes this setting for them.

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 10

JohnKHouston
Advocate
Advocate

Hi Adam,

 

Thanks very much for the code. I'll have a go at adding it in.

 

Cheers!

John

0 Likes
Message 4 of 10

JohnKHouston
Advocate
Advocate

I've tried to add this code myself but I haven't had any success. I don't really know how to add the code and I don't have the time to teach myself for this one task. I've also asked our reseller to see if they could assist us but they haven't responded to my request, so I'm forced to request some help here once again.

 

Would anyone be able to help in writing the necessary code to select an assembly and have all of the parts and assemblies modified to deselect the Advanced Feature Option?

 

I can't offer anything other than our eternal gratitude!

 

Thanks in advance for any help.

 

Best regards,

John

0 Likes
Message 5 of 10

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

This simply boils down to iterating through all the subcomponents of an assembly.

Have a look at "All Referenced Documents" section of this post: http://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html

 

You just have to modify it to change the setting you want. Something like this:

Public Sub ShowReferences() 
    ' Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument 
    Set oAsmDoc = ThisApplication.ActiveDocument

    ' Get all of the referenced documents. 
    Dim oRefDocs As DocumentsEnumerator 
    Set oRefDocs = oAsmDoc.AllReferencedDocuments 

    ' Iterate through the list of documents. 
    Dim oRefDoc As Document 
    For Each oRefDoc In oRefDocs 
        Debug.Print oRefDoc.DisplayName   
        If oRefDoc.ModelingSettings.AdvancedFeatureValidation Then
            oRefDoc.ModelingSettings.AdvancedFeatureValidation = False
            oRefDoc.Rebuild ' Not sure if this is needed in this scenario
        End If  
    Next 
End Sub  

 



Adam Nagy
Autodesk Platform Services
Message 6 of 10

Owner2229
Advisor
Advisor

Hi,

if you dont know how to add the code then here is how:

 

1) In Inventor pres Alt + F11

Window named "Microsoft Visual Basic For Application" should pop up

On left there should be "Application Project (Default.ivb)"

2) Expand it.

3) Right-click on "Modules" > "Insert" > "Module"

4) Paste the code adam.nagy posted.

5) Save and close "Microsoft Visual Basic For Application" window.

6) In Inventor in opened assembly go to "Tools" > "Customize"

7) In left tab expand the dropbox and select "Macros".

8) In right tab expand the dropbox and select "Assembly | Assembly"

9) In left tab select "ShowReferences".

10) Click on the arrows leading to right.

11) Click "Apply" and "Close".

12) In assembly go to "Assembly" tab and you should see there "User Commands". (On the right side of Ribbon)

13) The button should be there. Use it to run the code.

14) Give Kudos to Adam.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 7 of 10

JohnKHouston
Advocate
Advocate
Thanks, Mike, for helping to add a button to run Adam's code, I really appreciate it!
0 Likes
Message 8 of 10

JohnKHouston
Advocate
Advocate

Hi Adam,

 

This routine works well but it does stop when it comes up against iParts and content center parts. Would it be possible to modify the code to ignore those components?

 

I'm guessing it's mostly because they're read only type parts but it's only a guess. Thanks in advance for your help.

 

Best regards,

John

0 Likes
Message 9 of 10

Owner2229
Advisor
Advisor
Accepted solution

Hi, you should look for the document's subtype:

 

If oRefDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" _     ' Part proxy
Or oRefDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then  ' SheetMetal proxy
    ' Run the code
End If

So...

Public Sub ShowReferences() 
    ' Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument 
    Set oAsmDoc = ThisApplication.ActiveDocument

    ' Get all of the referenced documents. 
    Dim oRefDocs As DocumentsEnumerator 
    Set oRefDocs = oAsmDoc.AllReferencedDocuments 

    ' Iterate through the list of documents. 
    Dim oRefDoc As Document 
    For Each oRefDoc In oRefDocs 
        Debug.Print oRefDoc.DisplayName
If oRefDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" _ ' Part proxy Or oRefDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then ' SheetMetal proxy
If oRefDoc.ModelingSettings.AdvancedFeatureValidation Then
oRefDoc.ModelingSettings.AdvancedFeatureValidation = False
oRefDoc.Rebuild ' Not sure if this is needed in this scenario
End If
End If
Next
End Sub

 

Or you can place this at the start of the code (in the Sub Routine):

On Error Resume Next

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 10 of 10

JohnKHouston
Advocate
Advocate

The code, 'on error resume', worked. That's awesome, thank you very much!  😄

0 Likes