Clientfeature.HiddenParameters

Clientfeature.HiddenParameters

Anonymous
Not applicable
684 Views
4 Replies
Message 1 of 5

Clientfeature.HiddenParameters

Anonymous
Not applicable

Hello,

 

I'm trying to hide some parameters that are contained within my clientfeature. I've been trying to add parameters to the hidden parameters object collection through using the clientfeature.hiddenparameter property.

 

Are there any examples of this?

 

Thanks,

-Thomas

 

 

0 Likes
Accepted solutions (1)
685 Views
4 Replies
Replies (4)
Message 2 of 5

philippe.leefsma
Alumni
Alumni
Accepted solution

Hi Thomas,

 

This should be rather straightforward:

 

Sub CfParamsVisibility()

    Dim doc As Document
    Set doc = ThisApplication.ActiveDocument
    
    Dim features As PartFeatures
    Set features = doc.ComponentDefinition.features
    
    Dim def As ClientFeatureDefinition
    Set def = features.ClientFeatures.CreateDefinition
    
    Call def.ClientFeatureElements.Add(features(1), True)

    Dim cf As ClientFeature
    Set cf = features.ClientFeatures.Add(def, "ADN")
    
    Dim col As ObjectCollection
    Set col = ThisApplication.TransientObjects.CreateObjectCollection
    
    Dim param As parameter
    For Each param In cf.parameters
        col.Add param
    Next
    
    cf.HiddenParameters = col
    
End Sub

 Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Philippe,

 

Thanks for getting back to me.

 

 

After using a loop to add all the neccessary parameters into an object collection,

I found that I was using:

 

clientfeature.hiddenparameters.add(col)

 

rather than:

 

clientfeature.hiddenparameters = col to set the collection of hidden parameters.

 

Do you know why using the .add(col) method doesn't work? I was even trying to use .add(param) to add each parameter individually with no luck. (After I ran the code with .add(param), the .hiddenparameters.count  still equaled 0. Is there a bug with the add method?

 

Not a huge deal, just wondering.

 

Thanks for your help.

-Thomas

 

 

 

 

 

 

0 Likes
Message 4 of 5

philippe.leefsma
Alumni
Alumni

 

That's a vicious effect of the COM wrapped API, let's say you just have to do it this way, otherwise the change is not taken into account. The same approach applies for any similar workflow with the API, so be cautious about it.

 

Regards,

Philippe.

 

______________________________________________________________

If my post answers your question, please click the "Accept as Solution"

button. This helps everyone find answers more quickly!

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

Maxim-CADman77
Advisor
Advisor

Is there any prerequisites to running this code?

When I copy it to new module in build-in VB Editor (Inventor 2014) and run it I get "Run-time error '5': Invalid procedure call or argument" on Line "Call def.ClientFeatureElements.Add(features(1), True)"

Please vote for Inventor-Idea Text Search within Option Names

0 Likes