Changing the copied element

Changing the copied element

will_smith3691215
Participant Participant
1,175 Views
5 Replies
Message 1 of 6

Changing the copied element

will_smith3691215
Participant
Participant

hi, my task is to create a legend by copying another one and deleting all the objects from there (since there are no ways to create a legend in the revit api yet).
I also need to find all the windows in the legend; then, I need to copy any element of any legend; paste it into the newly created legend; change its type so that this element becomes a window from the list; and change it so that it appears in front of us with a front view. And so you need to repeat as many times as there are windows in the list. The result should be a new legend with all the windows from the document represented by the front view.
Unfortunately, I'm stuck halfway through. I copied the found element into a new legend and do not know how to change it, I have been doing this for literally several weeks now and have not made any progress. I am asking for your help in this seemingly easy task. I will attach my code below, I will be grateful for any hint and help, thank you in advance. I am not a native English speaker, so I can make various types of mistakes, for which I apologize.

0 Likes
Accepted solutions (1)
1,176 Views
5 Replies
Replies (5)
Message 2 of 6

ctm_mka
Collaborator
Collaborator

Have you verified you can do this manually? I was not aware you could show modeled elements in a Legend, but then i don't use Legends very often. Second, is it a code failure, or is it just not changing the element type?

Message 3 of 6

TripleM-Dev.net
Advisor
Advisor
Accepted solution

Hi @will_smith3691215,

 

As the specific parameters (attached to elements) used to do internal Revits "Stuff" isn't well documented use RevitLookup to inspect the elements and which parameters it that that (might) does what you need.

 

Looking into a LegendComponent, it's not a specific class, so no direct properties on the Class to use. (see: https://www.revitapidocs.com )

So inspecting a placed LegendComponent reveals the following builtin parameters:

BuiltinParameter.LEGEND_COMPONENT, which is of the ElementId datatype and takes the Id of a Type (wall type etc..) to determine which family type to show

 

BuiltinParameter.LEGEND_COMPONENT_VIEW, seems to be the one to determine the viewdirection, it's a integer type so change some Legendcomponents and see which value belongs to which direction (seems -5 = Section)

 

BuiltinParameter.LEGEND_COMPONENT_LENGTH, looks like this one controls the length of the component and is a double (length type).

 

- Michel

 

 

Message 4 of 6

will_smith3691215
Participant
Participant

Hi, I'm sorry for the late reply.
yes, I am sure that the component type can be changed using the api, and no, it was not a code error.
in fact, it was just necessary to use BuiltinParameter.LEGEND_COMPONENT as written TripleM-Dev.net see the answers below.
I am grateful to you for your time. Good luck)

0 Likes
Message 5 of 6

will_smith3691215
Participant
Participant

Hi, you were right, thank you so much.
to change the parameter type, I used BuiltinParameter.LEGEND_COMPONENT and it worked. I implemented it like this:
var parameter type = legendComponent.get_Parameter(BuiltInParameter.LEGEND_COMPONENT);
parametertype.Set(windows Symbol Id);
Now I am faced with the task of changing the appearance of the object to: Facade : front. I use a similar code but it doesn't work:
var parameter View = legendComponent.get_Parameter(BuiltInParameter.LEGEND_COMPONENT_VIEW);
parametertype.Set(-7);
do you have any thoughts on this?

0 Likes
Message 6 of 6

will_smith3691215
Participant
Participant

I'm sorry, I was inattentive and made a mistake. instead of "parameterView.Set(-7);" I used "parametertype.Set(-7);". after the correction, everything began to work as it should.

0 Likes