Setting the 'Label' parameter of TextElements via API

Setting the 'Label' parameter of TextElements via API

Anonymous
Not applicable
5,791 Views
21 Replies
Message 1 of 22

Setting the 'Label' parameter of TextElements via API

Anonymous
Not applicable

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?

0 Likes
5,792 Views
21 Replies
Replies (21)
Message 2 of 22

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 3 of 22

Anonymous
Not applicable

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!

0 Likes
Message 4 of 22

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 5 of 22

Anonymous
Not applicable

We speek about TextElements.

Edited by
Discussion_Admin

0 Likes
Message 6 of 22

Revitalizer
Advisor
Advisor

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





0 Likes
Message 7 of 22

Anonymous
Not applicable

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

 

 

0 Likes
Message 8 of 22

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 9 of 22

Anonymous
Not applicable

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

0 Likes
Message 10 of 22

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 11 of 22

Anonymous
Not applicable

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?!

 

 

 

 

0 Likes
Message 12 of 22

Anonymous
Not applicable

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;
        }
    }
    
}

0 Likes
Message 13 of 22

damian.szyjka
Explorer
Explorer

HI All,

 

Is there any news about Label Parameter?

0 Likes
Message 14 of 22

Dale.Bartlett
Collaborator
Collaborator

And now? Dale




______________
Yes, I'm Satoshi.
0 Likes
Message 15 of 22

Revitalizer
Advisor
Advisor

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 22

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 17 of 22

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 18 of 22

Anonymous
Not applicable

Was anything ever added to the API for this?

Message 19 of 22

Anonymous
Not applicable

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?

0 Likes
Message 20 of 22

nj19790605
Contributor
Contributor

I also want it