Duplicate an Element Type

Duplicate an Element Type

Anonymous
Not applicable
3,037 Views
4 Replies
Message 1 of 5

Duplicate an Element Type

Anonymous
Not applicable

Hi everyone,

 

To expose my problem, i'm trying to recreate in a personal windows Form i created, the same founctions 'duplicate' and 'set the element type' that we can be found in ''Edit Type'' for the selected element.

 

Sans titre.png

 

First Step, I tried to recreate the Button "Duplicate".

I follow the TBC article (http://thebuildingcoder.typepad.com/blog/2008/11/creating-a-new-family-symbol.html) but I have problems.

 

I use the fonction ElementType.Duplicate(NewTypeName). But i didn't arrive to get the selected ElementType.

 

This is my code :

 Dim newName As String = "new" & GlobalVariables.ElementName
 Dim elstype As ElementType = e.XXXXXXXXXXXXXXX
 Dim newType As ElementType = elstype.Duplicate(newName)

e.elstype = newType

 

 

e is the selected element

Dim e As Element = uidoc.Document.GetElement(id)

 

>> I think I miss a small part of code in place of the XXXXXXX.

 I don't know the way to get the elementtype and there is nothing related to this in the SDK revit 2016 package. I can get element, element id, type, type id, familly.... but nothing about an ElementType Class.

 

 

Thanks for your help !

 

Best Regards ,

 

Sylvain

 
 

 

0 Likes
Accepted solutions (1)
3,038 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Use the TypeId to get the type from the document using GetElement and casting the returned element as ElementType. e.g. ElementType eType = doc.GetElement(e.GetTypeId()) as ElementType;
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi,

 

Thanks a lot that's work great !

I didn't know we can do stuff like this.

 

I advance slowly, and now I didn't arrive to assign the new element type to the selected element...

 

I tried  "elstype = newType" but it did'nt work.

I think i should use 'ChangeTypeId()' Function, but i don't really understand how does it work. I tried :

 

newType.ChangeTypeId(id)

 

 

 

With id the ElementId of the selected Element.

 

I have the following error !

 

Sans titre.png

 

 

Thanks a lot for your help !!

 

Best regards,

Sylvain

0 Likes
Message 4 of 5

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

not

newType.ChangeTypeId(element.Id)

but

element.ChangeTypeId(newType.Id)

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 5

Anonymous
Not applicable

Tanks that work great !

 

I digress a little from the original subject. I would like to create the combobox with every ElementType.

 

I would like to filtered ElementType by a specific shared parameter value. I don't know how I can filtered through the Library Types and not only int the types drew in the project.

 

Hoping having a strating Help !!

 

Best regards,

Sylvain

 
 
 
 
0 Likes