Hi everyone,
I have been able to create a duct of specific width and height and add it to the project using doc.Create.NewDuct.
However, my target is to pass the width and height variabls to the internal duct drawing command (the one in the ribbon), is it possible? Thanks.
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Dear Lovetvseries,
No, I do not believe this is possible just like that.
What you can do, however, is determine the default type for the built-in command to place.
Look at the new Default Type API introduced in Revit 2015:
http://thebuildingcoder.typepad.com/blog/2014/04/whats-new-in-the-revit-2015-api.html#3.02
For instance, you can take a look at the SetDefaultFamilyTypeId method and the GetSetDefaultTypes SDK sample:
/a/lib/revit/2015/SDK_ur2/Samples/GetSetDefaultTypes/CS/DefaultFamilyTypes.xaml.cs
Once you have set the default type to the required dimensions, you can launch the built-in command using PostCommand.
I hope this helps.
Best regards,
Jeremy
I'm not sure but I think that Jeremy Tammik's solution doesn't solve the problem because you cannot set dimensions for DuctType. Width and height are instance parameters so I think that Jeremy's solutions doesn't work. It starts duct drawing but it uses last given width and height values. However if I'm wrong I'm intrested to hear how those dimensions are possible to set so that they are active when PostCommand is started.
Dear Hvarjus,
Thank you for your comments. You are very probably right. If the default type API cannot be used in this way, all I can think of suggesting is to insert a duct of the desired type and dimensions and then launch the 'Create Simiilar' command as suggested a long time ago for walls:
http://thebuildingcoder.typepad.com/blog/2010/11/launching-a-revit-command.html
Dear Lovetvseries, please let us know whether this helps and what solution you end up implementing.
Thank you!
Cheers,
Jeremy
Dear Jeremy,
I think so too that this "Create Similar" trick is only way to solve the problem with current Revit API. Your sample code is very old so Revit API currently offer little better method to start command via PostCommand method.
any volunteers? 🙂