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

Extract Shared Parameter Description

6 REPLIES 6
Reply
Message 1 of 7
Chris_BLTSMRT
1205 Views, 6 Replies

Extract Shared Parameter Description

Hi All,

 

This is the last hurdle for me in completing a rough V1.0 and so far I have not been able to determine whether or not the data I need is accessible.

 

I am working on a project where I need extract the description data from a shared parameter within a family instance. I have been able to access all of the other parameter information I need, but this one piece of data keeps eluding me.

 

The issue is that when I try to cast my parameter from an internal parameter to the external definition it comes back as 'null'  thus not allowing me to access the desired Description property.

 

Questions:

Can the Description of a shared parameter be accessed using only the family?

If so, what would be the best way to access and extract the data?

 

Version: Revit 2018

Language: C#

 

When the program gets to the "ExternalDefinition def" line it shows the property as 'null'.

foreach (Parameter p in sharedParams)
{
    ExternalDefinition def = p.Definition as ExternalDefinition
    file.WriteLine($"Parameter Name: {p.Definition.Name} Parameter Description: {def.Description}");
}

 

Labels (2)
6 REPLIES 6
Message 2 of 7
RPTHOMAS108
in reply to: Chris_BLTSMRT

It is null because ExternalDefinitions become InternalDefinitions once in the project or family document.

 

Not sure you can get this from the family either, there is FamilyManager.SetDescription not a get.

 

Would probably have to parse shared parameter file.

Message 3 of 7
Chris_BLTSMRT
in reply to: RPTHOMAS108

I see, that makes sense.

 

Parsing the Description from the file is not an option in this case since the file is not available.

 

So far the only solution is to transpose that portion through manual means which isn't ideal.

Message 4 of 7
RPTHOMAS108
in reply to: Chris_BLTSMRT

No there was an idea related to this however it was misrepresented in terms of being about the assignment of a tooltip rather than getting one. Assignment of tooltip is now implemented (although it was always easy with a manual SP file creation approach). So perhaps new idea related to getting a tooltip is now warranted.

https://forums.autodesk.com/t5/revit-ideas/assign-family-parameter-tooltip-description-from-the-api/...

 

This was the original discussion which lead to that idea.

https://forums.autodesk.com/t5/revit-api-forum/how-to-get-set-non-shared-parameter-tooltip-in-revit-...

 

In UI you can export a shared parameter into a SP file and get a tooltip that way. Same may be possible via post command but I haven't looked to see if it is post-able (probably isn't since it is contextual).

 

Message 5 of 7
Chris_BLTSMRT
in reply to: RPTHOMAS108

@RPTHOMAS108I appreciate all your help on this so far.

 

In looking at the linked topics in your reply, it seems the way I am currently approaching the problem won't work due to the Revit not having a "Get" command. I have used the set command for tool tips in other projects. Could you elaborate on the ability to export a shared parameter through the UI?

 

Does that technique require a specific shared parameter file to be associated with the project prior to exporting?

 

Thanks,

 

Chris

Message 6 of 7
RPTHOMAS108
in reply to: Chris_BLTSMRT

In the UI of a family document if you go into 

Create > Family Types

Pick the parameter and edit it (pencil icon) 

If there is a shared parameter file set then you can use the 'Export...' button and it will add the definition to that parameter file (button will not be available if attached SP file already contains it).

I doubt you could easily replicate this workflow with the API.

 

Outside of API might be possible but would require some form of windows automation technique which I don't often get involved with. I see people give similar windows automation suggestions for other things i.e. finding windows by handle/title and sending messages to click buttons and give things focus etc.

Message 7 of 7
Chris_BLTSMRT
in reply to: RPTHOMAS108

@RPTHOMAS108Wow I never knew about the export option if the parameter doesn't exist in the loaded shared parameter file! I am always learning something new!

 

Well, I think I have hit a block on the final step at this point. Luckily it was a small project and nothing too critical.

 

Thank you for your time!

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

Post to forums  

Rail Community


Autodesk Design & Make Report