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: 

Setting the 'Label' parameter of TextElements via API

20 REPLIES 20
Reply
Message 1 of 21
C.Kellner
3483 Views, 20 Replies

Setting the 'Label' parameter of TextElements via API

I'm trying to set the Label Parameter of TextElements via API in the same way like users do via GUI. Is there a way to set the parameter relationship to an elements parameter that receive the value and the TextElement that show the value in plans?

Tags (3)
20 REPLIES 20
Message 2 of 21
jeremytammik
in reply to: C.Kellner

I would expect it to be possible to achieve the same result programmatically as you do through the user interface.

 

Have you explored the database elements and their properties before and after setting up the label, e.g. using RevitLookup or the Ruby or Python shell?

 

That should give you a hint how to adress the issue throug the API as well.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 21
C.Kellner
in reply to: jeremytammik

Hoi Jeremy

 

I used RevitLookup to get the structure/ information I need. I found out that there is a BuiltInParameter called TAG_TAG with the StorageType None. This parameter is the parameter that a user fills with parameter references via GUI. An other BuiltInParameter called TAG_SAMPLE_TEXT contains sample values, dependent on the refered parameter, but how can I get or set the parameters that should be refered?!

 

I think one way is to set the value of the TextElements property Text using an own function. But I think its much better to use an on board API functionality!

Message 4 of 21
jeremytammik
in reply to: C.Kellner

Hoi hoi.

 

What exact objects are we talking about here? TextElement, TextNote, or what?

 

From you description, it sounds more like a tag element. IndependentTag?

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 21
C.Kellner
in reply to: C.Kellner

We speek about TextElements.

Edited by
Discussion_Admin

Message 6 of 21
Revitalizer
in reply to: jeremytammik

Hi Jeremy,

 

the topic is about TextElements, in Family context.

If you create a label family, you want the placed FamilyInstances to display certain parameters.

How to set the label parameter, by code ?

How to make a parameter to be connected to the label, in the Family document ?

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 21
C.Kellner
in reply to: Revitalizer

Hi Revitalizer,

 

that you for summerizing of my problem. Using a TextElement via GUI expact the selection of a parameter. This parameter sets the text value in the label. But how can I get or set this referenced parameter?

 

An other question is: Is there a way to have access to get the TextElements of a Tag without opening the family?

 

@jeremytammik You can use a independent tag revit, too. The question is: How can I set a value depending on a parameters value to the TextElement.Text attribute? I tried to use a TextNote but this is not a option because the value would be static and not dynamic.

 

Regards Christian

 

 

Message 8 of 21
jeremytammik
in reply to: C.Kellner

Dear Christian,

 

It sounds to me as if, if all else fails, you should be able to achieve this using the dynamic model updating framework DMU:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.31

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 9 of 21
C.Kellner
in reply to: jeremytammik

Hallo Jeremy,

 

I hoped you would have a better answer ! So the answer is that I build my own tags using TextNotes and Updater. But is there a way the get the subelements of a tag without opening the family editor (cause I think it is time expensive)?

 

Regards

 

Christian

Message 10 of 21
jeremytammik
in reply to: C.Kellner

Dear Christian,

 

I also still hope someone else has a better answer.

 

This suggestion just came to mind as a last resort.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 11 of 21
C.Kellner
in reply to: jeremytammik

Hello,

 

I have analysed the API for my problem but I don't found a solution. I can not believe that there is no way to get the referred parameters. I summarized the issue in a document. Maybe an other one can tell me whether the problem can be solved or not?!

 

 

 

 

Message 12 of 21
mwilson1
in reply to: C.Kellner

Well for what it's worth, I smashed my face against this problem, trying to set the label parameter of a TextElement in a family, and came up empty handed. I think our only hope is for a wishlist item =\.

 

Here is the code I'm using:

namespace test
{
    [TransactionAttribute(TransactionMode.Manual), RegenerationAttribute(RegenerationOption.Manual)]
    public class textelemtest : IExternalCommand
    {

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {

            UIApplication App = commandData.Application;
            Document famdoc = App.ActiveUIDocument.Document;
            
            FilteredElementCollector textcoll = new FilteredElementCollector(famdoc);
            ICollection<ElementId> textelementids = textcoll.OfClass(typeof(TextElement)).ToElementIds();
            Parameter label = null;
            foreach (ElementId id in textelementids)
            {
                Element elem = famdoc.GetElement(id);
                //there doesnt appear to be a builtinparameter for Label, selecting the parameter via the name =\
                foreach (Parameter p in elem.Parameters)
                {
                    if (p.Definition.Name == "Label")
                    {
                        label = p;
                    }
                }
                if (label != null)
                {
                    using (Transaction trans = new Transaction(famdoc))
                    {
                        trans.Start("Update Parameter");
                        //not sure how to set this parameter
                        label.Set(?????);
                        trans.Commit();
                    }
                }
            }
            
            return Result.Succeeded;
        }
    }
    
}

Tags (1)
Message 13 of 21
damian.szyjka
in reply to: mwilson1

HI All,

 

Is there any news about Label Parameter?

Message 14 of 21

And now? Dale




______________
Yes, I'm Satoshi.
Message 15 of 21
Revitalizer
in reply to: Dale.Bartlett

Hi,

 

I would recommend to bring it to the Idea Station.

https://forums.autodesk.com/t5/revit-ideas/idb-p/302/tab/most-recent

 

If there is already an existing idea for the issue, vote it up.

If not, create a new one.

 

The more votes, the higher the priority to be implemented.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 16 of 21

Dear Dale,

 

Are you aware of any wish list database entry number?

 

Is this submitted to the Revit Idea Station yet?

 

If not, I would suggest doing so right away.

 

Meanwhile, I am checking with the development team for you...

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 17 of 21
jeremytammik
in reply to: C.Kellner

We have an internal wish list item for this, CF-3799 [API access to read and write labels].

 

I added a link to this thread to that. 

 

I cannot find a Revit Ideas link about setting labels, but there is one about getting them:

 

https://forums.autodesk.com/t5/revit-ideas/api-get-shared-parameter-linked-to-a-label/idi-p/7077420

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 18 of 21

Was anything ever added to the API for this?

Message 19 of 21

Has there been an update on this? Would be a really useful feature?

I've seen @jeremytammik's handle show up across multiple posts, seems to be the Revit API wizard around?

Message 20 of 21
nj19790605
in reply to: tome.gouveia

I also want it

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community