Remove Template from View

Remove Template from View

Ryan
Enthusiast Enthusiast
3,958 Views
5 Replies
Message 1 of 6

Remove Template from View

Ryan
Enthusiast
Enthusiast

Hi All,

 

I have been trying to figure out how to  remove an assigned View Template from a view; Set it to "None". I know how to find a view template and get its ID and assign to a view, but when i look for "None" it doesn't come through on the FEC.

 

Ive tried setting the View.ID to -1, but does't work.

 

Is there something Simple I'm missing?

 

Thanks!

 

 

2015-06-08_0932.png

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

Anonymous
Not applicable
Accepted solution

Hi All,

 

You can in this way :

 

View vw = doc.ActiveView;
Transaction tr = new Transaction(doc,"template to none");
tr.Start();
Parameter par = vw.GetParameter("View Template");
par.Set(new ElementId(-1));   <----------- I think what you did is just type par.Set(-1) and that doesn't work. SO you need to 'convert' the int to elementid
tr.Commit();

 

 

Message 3 of 6

Ryan
Enthusiast
Enthusiast

Great! Thanks!

 

I didn't think of trying to convert the int to an ElementID.

0 Likes
Message 4 of 6

Anonymous
Not applicable
In general this is the trick whenever you'll need to set a parameter of the elementId type. It's taken me some headache before I'll discovered this trick 🙂
0 Likes
Message 5 of 6

IAN~JAMES
Advocate
Advocate
You are probably safer setting the value to ElementId.InvalidElementId as follows:

par.Set(ElementId.InvalidElementId);

So if anything changes under the hood in time to come, this should still work.
Message 6 of 6

v.slizen
Participant
Participant

When I'm writing "View Template", for method "GetParameter" then it didn't converting "string" to "Autodesk.Revit.DB.ForgeTypeId"

0 Likes