Here is an interesting question and a workaround for a problem accessing the visibility property on shared parameters, raised by Jon Smith of Construction Industry Solutions COINS:
Question: We need to be able to tell if a parameter is visible or invisible, so we can honour that setting in our own interface and not display it if set to invisible. We try to do this as follows:
ExternalDefinition externalDef = param.Definition as ExternalDefinition; if( externalDef == null || externalDef.Visible ) { // show the parameter }
However, all definitions returned by this method for any parameter whatsoever are InternalDefinition, including for shared parameters that have been marked as invisible. The InternalDefinition does not have the Visible property exposed.
It also seems, from looking in the Visual Studio watch window, that the base Definition class does contain a visible property (whose value is correct), but it is internal and not exposed:
Answer: Yes, there is a known issue accessing the definition class of a shared parameter. The Parameter.Definition property on a shared parameter erroneously returns an InternalDefinition, even though it actually should be returning an ExternalDefinition. This issue is being looked into and will be resolved soon. It may be possible to implement a workaround to get the proper external definition through the sequence Application.OpenSharedParameterFile > DefinitionFile > DefinitionGroup > ExternalDefinition.
Happily, if Visual Studio is able to display the visibility property that you are interested in, then you should also be able to access it from your application source code using .NET reflection.
Response: Excellent - thanks for the information on the issue with the Parameter.Definition property, and thanks for pointing me towards using reflection. We have created the following function that solves the problem for the current release:
public static bool isParameterVisible( Parameter p ) { bool bParameterIsVisible = true; try { BindingFlags flags = BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod; Type t = typeof( Definition ); object result = t.InvokeMember( "get_Visible", flags, null, p.Definition, null ); if( null != result && result is Boolean ) { bParameterIsVisible = (Boolean) result; } } catch( System.Exception ) { // in case of any problems, assume parameter is visible } return bParameterIsVisible; }
Many thanks to Jon for this cool little workaround!
Hi. I need to ask you. I think it´s not possible, but you are an expert with API and tell me if we can change the information of that SCALE LABEL, shown on titleblocks ? When we have two different scales on sheet, the value is AS INDICATED. But if I want to change to other thing ? If I need to translate to FRENCH or ITALIAN ?
Posted by: Ricardo Cardial | August 24, 2009 at 15:41
Dear Ricardo,
One easy way to check this is to use the built-in parameters checker which is part of the Revit API introduction labs, cf.
http://thebuildingcoder.typepad.com/blog/2009/04/deeper-parameter-exploration.html
I created a new sheet, selected the title block, and launched the built-in parameters checker. One of the parameters that it displays is the built-in parameter SHEET_SCALE with the display name 'Scale'. It is a string-valued parameter and is unfortunately marked as read-only.
Is that the one you are interested in? If so, then, as you can see, you seem to be out of luck. Being marked as read-only, it cannot be modified directly through the API. I'll ask around and see whether I can find any other way to modify this information.
Cheers, Jeremy.
Posted by: Jeremy Tammik | August 25, 2009 at 01:52
Dear Ricardo,
A colleague of mine, Phil Xia, has the following suggestion for you: How about modifying the title block of the sheet? It is a family, the texts can be modified or localized. Simply open the family file for editing and modify that.
Cheers, Jeremy.
Posted by: Jeremy Tammik | August 25, 2009 at 02:52
Hello Jeremy,
I'm new to this whole API thing and quite honestly, not quite sure I get it all so i'll be reading on that on the weeks to come. However, I was wondering if it is feasable to refer a family parameter (while building the family in REVIT) to a built-in parameter (such as SHEET_SCALE). For example, I could have a yes/no parameter showing either the label refering to the built-in parameter or the family parameter depending id SHEET_SCALE is showing "As indicated".
It might seem far fetch, but again I'm just getting started with the formulas, never mind the API.
Thank you,
Posted by: Sebastien Dubois | September 09, 2010 at 16:50
Dear Sebastien,
I should think that that is possible. Please have a look at the method AssociateElementParameterToFamilyParameter and the samples provided with the family API webcast:
http://thebuildingcoder.typepad.com/blog/2009/08/the-revit-family-api.html
http://thebuildingcoder.typepad.com/blog/2009/10/revit-family-creation-api-labs.html
Cheers, Jeremy.
Posted by: Jeremy Tammik | September 15, 2010 at 08:04
Dear sir,
Is this possible to hide/invisible a Family Parameter from Family Types?
Thanks & Regards,
-Nitin
Posted by: Account Deleted | August 03, 2011 at 00:57
Dear Nitin,
As far as I know, family parameters are always visible, aren't they?
Cheers, Jeremy.
Posted by: Jeremy Tammik | August 09, 2011 at 05:38
Dear sir,
I come to know that shared parameters can be invisible(tried some code), but till they are shown in Revit 'Family Types' window.
I m not able to understand this concept.
Please help.
Thanks & regards
-Nitin
Posted by: Account Deleted | August 11, 2011 at 10:45
Dear Nitin,
If you say so, then I guess that is the way it is.
I hope this helps :-)
Cheers, Jeremy.
Posted by: Jeremy Tammik | August 11, 2011 at 10:50
Dear sir,
Thanks for quick reply.
May i know in what situation is Visible property of shared parameter useful?
Thanks & Regards,
-Nitin
Posted by: Account Deleted | August 11, 2011 at 10:54
Dear Nitin,
In the project environment, as far as I know.
Cheers, Jeremy.
Posted by: Jeremy Tammik | August 11, 2011 at 11:20
Dear Sir,
I want to change scale displayed on sheet "As Indicated" to "As shown".I have got only Revit 2012 only could you please advise me.
Regards,
Vikas
Posted by: vikas | February 27, 2012 at 03:21
Dear Vikas,
Can you achieve what you need manually through the user interface? If not, it is probably not possible through the API either.
Cheers, Jeremy.
Posted by: Jeremy Tammik | February 29, 2012 at 06:46
Hello Jeremy,is it possible to make shared parameter non editable?
Posted by: sandeep Kumar | February 22, 2013 at 02:17
Dear Sandeep,
No, not really.
Cheers, Jeremy.
Posted by: Jeremy Tammik | March 13, 2013 at 02:52