<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: postable command usage in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388803#M35820</link>
    <description>&lt;P&gt;See here.&lt;/P&gt;&lt;P&gt;&lt;A href="https://boostyourbim.wordpress.com/2013/01/14/how-to-override-commands-in-the-revit-ui-if-you-really-dont-want-people-to-import-cad-files/" target="_blank"&gt;https://boostyourbim.wordpress.com/2013/01/14/how-to-override-commands-in-the-revit-ui-if-you-really-dont-want-people-to-import-cad-files/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Mar 2020 04:35:00 GMT</pubDate>
    <dc:creator>Sean_Page</dc:creator>
    <dc:date>2020-03-20T04:35:00Z</dc:date>
    <item>
      <title>postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9386292#M35811</link>
      <description>&lt;P&gt;seems postable command usage is quite limited, for instance&lt;/P&gt;&lt;P&gt;1) can only send warning message instead of disable command?&lt;/P&gt;&lt;P&gt;2) OOTB duplicate view will name that duplicated view w/ suffix Copy 1, is it possible to name it differently?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 04:09:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9386292#M35811</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-19T04:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9386577#M35812</link>
      <description>&lt;P&gt;Regarding your question 2, you could react to the new view creation and rename it afterwards in an additional step, either using DMU or the document changed event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 08:34:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9386577#M35812</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-03-19T08:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9386607#M35813</link>
      <description>&lt;P&gt;right, i'll give it a try, thanks Jeremy!&lt;/P&gt;&lt;P&gt;by the way, don't know if i can use&amp;nbsp;ElementTypeDuplicated Event? i assume view duplicating is instance based operation, isn't it?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 08:57:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9386607#M35813</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-19T08:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388774#M35814</link>
      <description>&lt;P&gt;If you add Command Binding to the applicable Postable Commands you can indeed disable them by just making them do nothing, or giving the user a warning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DMU is my preferred method to catch new views and rename them.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 03:32:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388774#M35814</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-03-20T03:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388775#M35815</link>
      <description>&lt;P&gt;i did a quick test using document changed event, seems i cannot start transaction in order to change view name, did i miss something?&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;public void AppDocumentChanged(object sender, Autodesk.Revit.DB.Events.DocumentChangedEventArgs args)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;ICollection&amp;lt;ElementId&amp;gt; views = new FilteredElementCollector(doc).OfClass(typeof(View)).ToElementIds();&lt;/P&gt;&lt;P&gt;ICollection&amp;lt;ElementId&amp;gt; ids = args.GetAddedElementIds();&lt;BR /&gt;foreach (ElementId id in ids)&lt;BR /&gt;if (views.Contains(id))&lt;BR /&gt;{&lt;BR /&gt;Element e = doc.GetElement(id);&lt;BR /&gt;string name = Regex.Replace(e.Name, @" Copy 1", "_zn"); // name changed successfully&lt;BR /&gt;using (Transaction tx = new Transaction(doc))&lt;BR /&gt;{&lt;BR /&gt;tx.Start("renameTransaction");&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;e.Name = name;&lt;BR /&gt;}&lt;BR /&gt;catch (Exception ex)&lt;BR /&gt;{&lt;BR /&gt;MessageBox.Show(ex.Message);&lt;BR /&gt;}&lt;BR /&gt;tx.Commit();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 03:33:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388775#M35815</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-20T03:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388780#M35816</link>
      <description>&lt;P&gt;I do not believe you can produce a Transaction during this event. It is a read only event according to the docs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.revitapidocs.com/2015/988dd6cf-fcaa-85d2-622d-c50f13917a13.htm" target="_blank"&gt;https://www.revitapidocs.com/2015/988dd6cf-fcaa-85d2-622d-c50f13917a13.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is why DMU is so nice, it happens in a transaction already so no need to start another one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 03:38:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388780#M35816</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-03-20T03:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388782#M35817</link>
      <description>&lt;P&gt;Also, are you missing { } on your foreach?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 03:42:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388782#M35817</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-03-20T03:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388789#M35818</link>
      <description>&lt;P&gt;thanks spage, can you elaborate on&amp;nbsp;&lt;SPAN&gt;Command Binding thing to disable / give warning? yes, i'll try DMU later as suggested by Jeremy too&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 04:12:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388789#M35818</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-20T04:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388792#M35819</link>
      <description>&lt;P&gt;good to know that document changed event is read only, perhaps factory should provide us w/ document changing event too?&lt;/P&gt;&lt;P&gt;i skipped {} as only one if statement here, well, not good practice, thanks again&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 04:15:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388792#M35819</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-20T04:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388803#M35820</link>
      <description>&lt;P&gt;See here.&lt;/P&gt;&lt;P&gt;&lt;A href="https://boostyourbim.wordpress.com/2013/01/14/how-to-override-commands-in-the-revit-ui-if-you-really-dont-want-people-to-import-cad-files/" target="_blank"&gt;https://boostyourbim.wordpress.com/2013/01/14/how-to-override-commands-in-the-revit-ui-if-you-really-dont-want-people-to-import-cad-files/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 04:35:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388803#M35820</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-03-20T04:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388886#M35821</link>
      <description>&lt;P&gt;thanks spage, works great! what if i want to give warning only and continue that command in OOTB way?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 06:19:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388886#M35821</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-20T06:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388891#M35822</link>
      <description>&lt;P&gt;You would need to Remove the command binding after the warning and the use a PostCommand to call the initial CommandId.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also use Idle handlers to create the binding again if you want it to happen every time and not just the first time.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 06:25:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9388891#M35822</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-03-20T06:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9389090#M35823</link>
      <description>&lt;P&gt;right, i need to use idle stuff to make sure it works every time, thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 09:27:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9389090#M35823</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-20T09:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9392961#M35824</link>
      <description>&lt;P&gt;hi spage, for idle event, which scope should i put into, app or cmd? if i put&amp;nbsp;@ app scope i.e. startup then it's one time only, if i put&amp;nbsp;@ cmd scope then how can i use OOTB import command instead of addin command?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 06:39:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9392961#M35824</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-23T06:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9393649#M35825</link>
      <description>&lt;P&gt;So I have it in the Application level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. On Startup Biding and capturing the application for later use.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public Result OnStartup(UIControlledApplication application)
        {
            ControlID.application = application;
            AddCommandBindings(application, "ID_INPLACE_COMPONENT");
            return Result.Succeeded;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Add the Command Binding and the Method to call when it captures the command.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private Result AddCommandBindings(UIControlledApplication application, string name)
        {
            RevitCommandId rCommandId = RevitCommandId.LookupCommandId(name);
            if (rCommandId.CanHaveBinding)
            {
                try
                {
                    if (name == "ID_INPLACE_COMPONENT")
                    {
                        application.CreateAddInCommandBinding(rCommandId).Executed += new EventHandler&amp;lt;ExecutedEventArgs&amp;gt;(this.DisableCommand);
                    }
                }
                catch
                {
                    MessageBox.Show("Command " + name + " is already bound.");
                }
            }
            return Result.Succeeded;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. This is the Method the CommandBinding calls when fired&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void DisableCommand(object sender, ExecutedEventArgs args)
        {
            ControlID.postCommand = args.CommandId.Name;
            using (Forms.RevitPostCommandForm rpc = new Forms.RevitPostCommandForm())
            {
                if (rpc.ShowDialog() == DialogResult.OK)
                {
                    UIDocument uiDoc = new UIDocument(args.ActiveDocument);
                    uiDoc.Application.RemoveAddInCommandBinding(args.CommandId);
                    uiDoc.Application.PostCommand(args.CommandId);
                    ControlID.application.Idling += new EventHandler&amp;lt;IdlingEventArgs&amp;gt;(InPlaceComponent_Idling);
                }
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. Use the associated idling event to Add the command binding back after it has fired the second time.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private void InPlaceComponent_Idling(object sender, IdlingEventArgs args)
        {
            AddCommandBindings(ControlID.application, "ID_INPLACE_COMPONENT");
            ControlID.application.Idling -= InPlaceComponent_Idling;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; public static class ControlID
        {
            public static UIControlledApplication application { get; set; }
         }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 13:26:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9393649#M35825</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-03-23T13:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9395100#M35826</link>
      <description>&lt;P&gt;thanks spage, works great! except that i have to click OK twice, means that DisableCommand being executed twice, i assume it cannot be avoided because that same command being posted again, perhaps if i missed something?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 01:54:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9395100#M35826</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-24T01:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9395216#M35827</link>
      <description>&lt;P&gt;I am not somewhere I can test, but I think the Postcommand is queued until after all the other code runs, which means the Idling event is actually firing first. Maybe a Thread.Sleep(2000) in the Idling will give the PostCommand a chance to fire. Not positive on that.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 03:18:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9395216#M35827</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-03-24T03:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9395296#M35828</link>
      <description>&lt;P&gt;i did quick test, no, doesn't work, just delayed.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 04:32:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9395296#M35828</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-24T04:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9397392#M35829</link>
      <description>&lt;P&gt;Looking back at my code which is working for me, the only thing I see is that I have the idler handler BEFORE the post command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void DisableCommand(object sender, ExecutedEventArgs args)
        {
            ControlID.postCommand = args.CommandId.Name;
            using (Forms.RevitPostCommandForm rpc = new Forms.RevitPostCommandForm())
            {
                if (rpc.ShowDialog() == DialogResult.OK)
                {
                    UIDocument uiDoc = new UIDocument(args.ActiveDocument);
                    uiDoc.Application.RemoveAddInCommandBinding(args.CommandId);
                    ControlID.application.Idling += new EventHandler&amp;lt;IdlingEventArgs&amp;gt;(InPlaceComponent_Idling);
                    uiDoc.Application.PostCommand(args.CommandId);
                }
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 18:05:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9397392#M35829</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-03-24T18:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: postable command usage</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9398200#M35830</link>
      <description>&lt;P&gt;thanks spage, still doesn't work, the only difference is that i used window message box&lt;/P&gt;&lt;P&gt;DialogResult result = MessageBox.Show("click OK to continue importing but your action will be logged", "BIM &amp;amp; DD", MessageBoxButtons.OKCancel);&lt;BR /&gt;if (result == DialogResult.OK)&lt;BR /&gt;{&lt;BR /&gt;uiApp.RemoveAddInCommandBinding(arg.CommandId);&lt;BR /&gt;uiApp.Idling += new EventHandler&amp;lt;IdlingEventArgs&amp;gt;(OnIdling);&lt;BR /&gt;uiApp.PostCommand(arg.CommandId);&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 01:19:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/postable-command-usage/m-p/9398200#M35830</guid>
      <dc:creator>Ning_Zhou</dc:creator>
      <dc:date>2020-03-25T01:19:20Z</dc:date>
    </item>
  </channel>
</rss>

