<?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 detect command execution .net in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475536#M83457</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I'm using VS 2003 .NET and the ObjectARX 2006 SDK to develop an application to Autocad 2006. I wonder if it's possible to detect whan the user run a command like offset, line, mirror, etc... When detect I whant to show a message with a question to the user and, depending on the answer (Yes or No), the command will continue or abort the command execution. I'm using VB to develop but I'm familiar with C# to.&lt;BR /&gt;
&lt;BR /&gt;
Is this possible?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your attention. I'll be wating for an answer.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Filipe Marcelino</description>
    <pubDate>Wed, 02 Nov 2005 12:40:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2005-11-02T12:40:38Z</dc:date>
    <item>
      <title>detect command execution .net</title>
      <link>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475536#M83457</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I'm using VS 2003 .NET and the ObjectARX 2006 SDK to develop an application to Autocad 2006. I wonder if it's possible to detect whan the user run a command like offset, line, mirror, etc... When detect I whant to show a message with a question to the user and, depending on the answer (Yes or No), the command will continue or abort the command execution. I'm using VB to develop but I'm familiar with C# to.&lt;BR /&gt;
&lt;BR /&gt;
Is this possible?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your attention. I'll be wating for an answer.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Filipe Marcelino</description>
      <pubDate>Wed, 02 Nov 2005 12:40:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475536#M83457</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-11-02T12:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: detect command execution .net</title>
      <link>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475537#M83458</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I already could figured out how to detect a command execution:&lt;BR /&gt;
&lt;BR /&gt;
m_doc = Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;
Private Shared Sub m_doc_CommandWillStart(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.CommandEventArgs) Handles m_doc.CommandWillStart&lt;BR /&gt;
    Dim _frm As New frmChangeLayer&lt;BR /&gt;
    _frm.ShowDialog()&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'-----------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
Public Class frmChangeLayer&lt;BR /&gt;
    Inherits System.Windows.Forms.Form&lt;BR /&gt;
&lt;BR /&gt;
'Initializes the combobox with a list of all layers existing&lt;BR /&gt;
    Public Sub New()&lt;BR /&gt;
        MyBase.New()&lt;BR /&gt;
&lt;BR /&gt;
        'This call is required by the Windows Form Designer.&lt;BR /&gt;
        InitializeComponent()&lt;BR /&gt;
&lt;BR /&gt;
        'Add any initialization after the InitializeComponent() call&lt;BR /&gt;
    Application.DocumentManager.MdiActiveDocument.LockDocument(DocumentLockMode.AutoWrite, Nothing, Nothing, True)&lt;BR /&gt;
    Dim curdb As Database = Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;
    Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = curdb.TransactionManager&lt;BR /&gt;
    Dim myT As Transaction = tm.StartTransaction()&lt;BR /&gt;
    Try&lt;BR /&gt;
        Dim lt As LayerTable = CType(tm.GetObject(curdb.LayerTableId, OpenMode.ForRead), LayerTable)&lt;BR /&gt;
        For Each objId As ObjectId In lt&lt;BR /&gt;
            ComboBox1.Items.Add(CType(tm.GetObject(objId, OpenMode.ForRead), LayerTableRecord).Name)&lt;BR /&gt;
        Next&lt;BR /&gt;
        myT.Commit()&lt;BR /&gt;
    Catch ex As Exception&lt;BR /&gt;
        myT.Abort()&lt;BR /&gt;
        MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)&lt;BR /&gt;
    Finally&lt;BR /&gt;
        myT.Dispose()&lt;BR /&gt;
    End Try&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;BR /&gt;
    Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;
    Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager&lt;BR /&gt;
    Dim myT As Transaction = tm.StartTransaction()&lt;BR /&gt;
    Dim ExistingLayerId As ObjectId&lt;BR /&gt;
    Dim elt As LayerTable = CType(tm.GetObject(db.LayerTableId, OpenMode.ForWrite, False), LayerTable)&lt;BR /&gt;
    ExistingLayerId = elt.Item(ComboBox1.SelectedItem)&lt;BR /&gt;
    Dim curLay As ObjectId = db.Clayer&lt;BR /&gt;
    db.Clayer = ExistingLayerId&lt;BR /&gt;
    ' Do something&lt;BR /&gt;
    db.Clayer = curLay&lt;BR /&gt;
    myT.Commit()&lt;BR /&gt;
    myT.Dispose()&lt;BR /&gt;
    Close()&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click&lt;BR /&gt;
    Close()&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
End Class&lt;BR /&gt;
&lt;BR /&gt;
------------------------------------------------------------&lt;BR /&gt;
This should work but what happends is, when I show my form (frmChangeLayer) the LayerManager is blocked. I think that's why my algorithm doesn't change current layer.&lt;BR /&gt;
&lt;BR /&gt;
Does anyone knows a way to do this? Change the current layer before a command execution programmatically?&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Filipe Marcelino</description>
      <pubDate>Thu, 03 Nov 2005 10:05:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475537#M83458</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-11-03T10:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: detect command execution .net</title>
      <link>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475538#M83459</link>
      <description>You wrote:&lt;BR /&gt;
"Application.DocumentManager.MdiActiveDocument.LockDocument(DocumentLockMode.Aut oWrite, Nothing, Nothing, True)"&lt;BR /&gt;
that means locking the database by your current thread.&lt;BR /&gt;
But I did not see unblock&lt;BR /&gt;
It would look like:&lt;BR /&gt;
&lt;BR /&gt;
Dim ld as DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument(DocumentLockMode.Aut oWrite, Nothing, Nothing, True)&lt;BR /&gt;
&lt;YOUR code=""&gt;&lt;BR /&gt;
ld.Dispose()  '--  it will unlock the database,&lt;BR /&gt;
&lt;BR /&gt;
I suggest you to try &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/YOUR&gt;</description>
      <pubDate>Thu, 03 Aug 2006 19:55:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475538#M83459</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-08-03T19:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: detect command execution .net</title>
      <link>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475539#M83460</link>
      <description>You may also see the extended sample at:&lt;BR /&gt;
http://discussion.autodesk.com/servlet/JiveServlet/download/152-459176-5106557-102154/BoundingBox.txt&lt;BR /&gt;
&lt;BR /&gt;
regards,&lt;BR /&gt;
networker</description>
      <pubDate>Thu, 03 Aug 2006 19:59:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/detect-command-execution-net/m-p/1475539#M83460</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-08-03T19:59:10Z</dc:date>
    </item>
  </channel>
</rss>

