<?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: changing drawing in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188105#M75442</link>
    <description>You are right. Here is the code with the error:&lt;BR /&gt;
&lt;BR /&gt;
Private Function CreateLayer(ByVal strucNewLayer As LayerStruc) As ObjectId 'identiek aan 'Private Function CheckLayer(ByVal newLayer As LayerStruc) As ObjectId&lt;BR /&gt;
        'the return value for this function&lt;BR /&gt;
        Dim layerId As ObjectId&lt;BR /&gt;
        Using tr As Transaction = db.TransactionManager.StartTransaction()&lt;BR /&gt;
            Try&lt;BR /&gt;
                'Controleren of de laag al bestaat ...&lt;BR /&gt;
                If LayerExists(strucNewLayer.Name) Then&lt;BR /&gt;
                    'Eerst de layertable ophalen en openen voor lezen&lt;BR /&gt;
                    Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForRead), LayerTable)&lt;BR /&gt;
                    'Ophalen laag&lt;BR /&gt;
                    layerId = GetLayer(strucNewLayer.Name)&lt;BR /&gt;
                    Dim ltr As LayerTableRecord = DirectCast(tr.GetObject(layerId, OpenMode.ForWrite), LayerTableRecord)&lt;BR /&gt;
                    'laagkleur instellen&lt;BR /&gt;
                    ltr.Color = Color.FromColorIndex(ColorMethod.ByLayer, strucNewLayer.col.ColorIndex) '/strucNewLayer.col&lt;BR /&gt;
                    'linetype er aan koppelen&lt;BR /&gt;
                    ltr.LinetypeObjectId = GetLineTypeId(strucNewLayer.LineType)&lt;BR /&gt;
                    'visible instellen               &lt;BR /&gt;
                    ltr.IsOff = Not (strucNewLayer.Visible)&lt;BR /&gt;
                    'isPlottable instellen &lt;BR /&gt;
                    ltr.IsPlottable = strucNewLayer.IsPlottable&lt;BR /&gt;
                    'Locked instellen&lt;BR /&gt;
                    ltr.IsLocked = strucNewLayer.IsLocked&lt;BR /&gt;
                    'Frozen instellen&lt;BR /&gt;
                    ltr.IsFrozen = False&lt;BR /&gt;
                Else&lt;BR /&gt;
                    'Laag aanmaken&lt;BR /&gt;
                    Dim ltr As LayerTableRecord = New LayerTableRecord()&lt;BR /&gt;
                    'laagnaam instellen&lt;BR /&gt;
                    ltr.Name = strucNewLayer.Name&lt;BR /&gt;
                    'laagkleur instellen&lt;BR /&gt;
                    ltr.Color = Color.FromColorIndex(ColorMethod.ByLayer, strucNewLayer.col.ColorIndex) '/strucNewLayer.col&lt;BR /&gt;
                    'linetype er aan koppelen&lt;BR /&gt;
                    ltr.LinetypeObjectId = GetLineTypeId(strucNewLayer.LineType)&lt;BR /&gt;
                    'visible instellen               &lt;BR /&gt;
                    ltr.IsOff = Not (strucNewLayer.Visible)&lt;BR /&gt;
                    'isPlottable instellen &lt;BR /&gt;
                    ltr.IsPlottable = strucNewLayer.IsPlottable&lt;BR /&gt;
                    'Locked instellen&lt;BR /&gt;
                    ltr.IsLocked = strucNewLayer.IsLocked&lt;BR /&gt;
                    'Frozen instellen&lt;BR /&gt;
                    ltr.IsFrozen = False&lt;BR /&gt;
                    'laag toevoegen&lt;BR /&gt;
                    Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForWrite), LayerTable)&lt;BR /&gt;
                    layerId = lt.Add(ltr)&lt;BR /&gt;
                    tr.AddNewlyCreatedDBObject(ltr, True)&lt;BR /&gt;
                End If&lt;BR /&gt;
                tr.Commit()&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
                tr.Dispose()&lt;BR /&gt;
                layerId = Nothing&lt;BR /&gt;
            End Try&lt;BR /&gt;
        End Using&lt;BR /&gt;
        'laagId teruggeven&lt;BR /&gt;
        Return layerId&lt;BR /&gt;
&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
The code itself is working, when executed from an other place. In this case this function gives the error in the statement:&lt;BR /&gt;
Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForWrite), LayerTable)&lt;BR /&gt;
The reported error is "locked database".&lt;BR /&gt;
The switching of the database in the handler doesn't go well.&lt;BR /&gt;
&lt;BR /&gt;
Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Gerard van der Sel</description>
    <pubDate>Mon, 25 Feb 2008 12:22:32 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-02-25T12:22:32Z</dc:date>
    <item>
      <title>changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188103#M75440</link>
      <description>I use the handler DocumentBecameCurrent to detect a switching of drawings.  When I try to use the database to check for non existing layers I got an fatal error.&lt;BR /&gt;
&lt;BR /&gt;
I use the following code:&lt;BR /&gt;
&lt;BR /&gt;
On load of the dll the handler is loaded:&lt;BR /&gt;
 Public Sub Initialize() Implements IExtensionApplication.Initialize&lt;BR /&gt;
        '----------------------------------------&lt;BR /&gt;
        AddHandler Application, AddressOf SwitchStart&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
At drawing switch the following handler is executed. The error occurs in Layers = New LayerManager&lt;BR /&gt;
Here the layers are checked and if the do not exist created.&lt;BR /&gt;
Public Sub SwitchStart(ByVal Sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DocumentCollectionEventArgs)&lt;BR /&gt;
        ' Make reference to drawing / Database&lt;BR /&gt;
        ed = e.Document.Editor 'Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        db = e.Document.Database 'HostApplicationServices.WorkingDatabase&lt;BR /&gt;
        ' Make a new Layermanager&lt;BR /&gt;
        Layers = New LayerManager&lt;BR /&gt;
        Layers.DetectTrackLayers()&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Has any one a clue off the error?&lt;BR /&gt;
&lt;BR /&gt;
Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Gerard van der Sel.</description>
      <pubDate>Mon, 25 Feb 2008 07:48:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188103#M75440</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-25T07:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188104#M75441</link>
      <description>You should't expect to get help with a problem if you don't post the code where the problem is occuring.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;SELG&gt; wrote in message news:5857105@discussion.autodesk.com...&lt;BR /&gt;
I use the handler DocumentBecameCurrent to detect a switching of drawings.  When I try to use the database to check for non existing layers I got an fatal error.&lt;BR /&gt;
&lt;BR /&gt;
I use the following code:&lt;BR /&gt;
&lt;BR /&gt;
On load of the dll the handler is loaded:&lt;BR /&gt;
 Public Sub Initialize() Implements IExtensionApplication.Initialize&lt;BR /&gt;
        '----------------------------------------&lt;BR /&gt;
        AddHandler Application, AddressOf SwitchStart&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
At drawing switch the following handler is executed. The error occurs in Layers = New LayerManager&lt;BR /&gt;
Here the layers are checked and if the do not exist created.&lt;BR /&gt;
Public Sub SwitchStart(ByVal Sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DocumentCollectionEventArgs)&lt;BR /&gt;
        ' Make reference to drawing / Database&lt;BR /&gt;
        ed = e.Document.Editor 'Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        db = e.Document.Database 'HostApplicationServices.WorkingDatabase&lt;BR /&gt;
        ' Make a new Layermanager&lt;BR /&gt;
        Layers = New LayerManager&lt;BR /&gt;
        Layers.DetectTrackLayers()&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Has any one a clue off the error?&lt;BR /&gt;
&lt;BR /&gt;
Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Gerard van der Sel.&lt;/SELG&gt;</description>
      <pubDate>Mon, 25 Feb 2008 12:08:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188104#M75441</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-25T12:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188105#M75442</link>
      <description>You are right. Here is the code with the error:&lt;BR /&gt;
&lt;BR /&gt;
Private Function CreateLayer(ByVal strucNewLayer As LayerStruc) As ObjectId 'identiek aan 'Private Function CheckLayer(ByVal newLayer As LayerStruc) As ObjectId&lt;BR /&gt;
        'the return value for this function&lt;BR /&gt;
        Dim layerId As ObjectId&lt;BR /&gt;
        Using tr As Transaction = db.TransactionManager.StartTransaction()&lt;BR /&gt;
            Try&lt;BR /&gt;
                'Controleren of de laag al bestaat ...&lt;BR /&gt;
                If LayerExists(strucNewLayer.Name) Then&lt;BR /&gt;
                    'Eerst de layertable ophalen en openen voor lezen&lt;BR /&gt;
                    Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForRead), LayerTable)&lt;BR /&gt;
                    'Ophalen laag&lt;BR /&gt;
                    layerId = GetLayer(strucNewLayer.Name)&lt;BR /&gt;
                    Dim ltr As LayerTableRecord = DirectCast(tr.GetObject(layerId, OpenMode.ForWrite), LayerTableRecord)&lt;BR /&gt;
                    'laagkleur instellen&lt;BR /&gt;
                    ltr.Color = Color.FromColorIndex(ColorMethod.ByLayer, strucNewLayer.col.ColorIndex) '/strucNewLayer.col&lt;BR /&gt;
                    'linetype er aan koppelen&lt;BR /&gt;
                    ltr.LinetypeObjectId = GetLineTypeId(strucNewLayer.LineType)&lt;BR /&gt;
                    'visible instellen               &lt;BR /&gt;
                    ltr.IsOff = Not (strucNewLayer.Visible)&lt;BR /&gt;
                    'isPlottable instellen &lt;BR /&gt;
                    ltr.IsPlottable = strucNewLayer.IsPlottable&lt;BR /&gt;
                    'Locked instellen&lt;BR /&gt;
                    ltr.IsLocked = strucNewLayer.IsLocked&lt;BR /&gt;
                    'Frozen instellen&lt;BR /&gt;
                    ltr.IsFrozen = False&lt;BR /&gt;
                Else&lt;BR /&gt;
                    'Laag aanmaken&lt;BR /&gt;
                    Dim ltr As LayerTableRecord = New LayerTableRecord()&lt;BR /&gt;
                    'laagnaam instellen&lt;BR /&gt;
                    ltr.Name = strucNewLayer.Name&lt;BR /&gt;
                    'laagkleur instellen&lt;BR /&gt;
                    ltr.Color = Color.FromColorIndex(ColorMethod.ByLayer, strucNewLayer.col.ColorIndex) '/strucNewLayer.col&lt;BR /&gt;
                    'linetype er aan koppelen&lt;BR /&gt;
                    ltr.LinetypeObjectId = GetLineTypeId(strucNewLayer.LineType)&lt;BR /&gt;
                    'visible instellen               &lt;BR /&gt;
                    ltr.IsOff = Not (strucNewLayer.Visible)&lt;BR /&gt;
                    'isPlottable instellen &lt;BR /&gt;
                    ltr.IsPlottable = strucNewLayer.IsPlottable&lt;BR /&gt;
                    'Locked instellen&lt;BR /&gt;
                    ltr.IsLocked = strucNewLayer.IsLocked&lt;BR /&gt;
                    'Frozen instellen&lt;BR /&gt;
                    ltr.IsFrozen = False&lt;BR /&gt;
                    'laag toevoegen&lt;BR /&gt;
                    Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForWrite), LayerTable)&lt;BR /&gt;
                    layerId = lt.Add(ltr)&lt;BR /&gt;
                    tr.AddNewlyCreatedDBObject(ltr, True)&lt;BR /&gt;
                End If&lt;BR /&gt;
                tr.Commit()&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
                tr.Dispose()&lt;BR /&gt;
                layerId = Nothing&lt;BR /&gt;
            End Try&lt;BR /&gt;
        End Using&lt;BR /&gt;
        'laagId teruggeven&lt;BR /&gt;
        Return layerId&lt;BR /&gt;
&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
The code itself is working, when executed from an other place. In this case this function gives the error in the statement:&lt;BR /&gt;
Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForWrite), LayerTable)&lt;BR /&gt;
The reported error is "locked database".&lt;BR /&gt;
The switching of the database in the handler doesn't go well.&lt;BR /&gt;
&lt;BR /&gt;
Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Gerard van der Sel</description>
      <pubDate>Mon, 25 Feb 2008 12:22:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188105#M75442</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-25T12:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188106#M75443</link>
      <description>In general, I don't think it is possible to do what you are trying to do from the DocumentBecameCurrent handler.&lt;BR /&gt;
&lt;BR /&gt;
The reason is because the handler can fire at any time, including when there is something happening in the document that is being made current. For example, a command may be in progress, and the document could be locked and not accessable at that point.&lt;BR /&gt;
&lt;BR /&gt;
If you would care to describe more generally, your need (e.g., why you need to create layers at that point), perhaps we can suggest another approach, but I very much doubt that the one you're pursuing is going to work.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;SELG&gt; wrote in message news:5857134@discussion.autodesk.com...&lt;BR /&gt;
You are right. Here is the code with the error:&lt;BR /&gt;
&lt;BR /&gt;
Private Function CreateLayer(ByVal strucNewLayer As LayerStruc) As ObjectId 'identiek aan 'Private Function CheckLayer(ByVal newLayer As LayerStruc) As ObjectId&lt;BR /&gt;
        'the return value for this function&lt;BR /&gt;
        Dim layerId As ObjectId&lt;BR /&gt;
        Using tr As Transaction = db.TransactionManager.StartTransaction()&lt;BR /&gt;
            Try&lt;BR /&gt;
                'Controleren of de laag al bestaat ...&lt;BR /&gt;
                If LayerExists(strucNewLayer.Name) Then&lt;BR /&gt;
                    'Eerst de layertable ophalen en openen voor lezen&lt;BR /&gt;
                    Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForRead), LayerTable)&lt;BR /&gt;
                    'Ophalen laag&lt;BR /&gt;
                    layerId = GetLayer(strucNewLayer.Name)&lt;BR /&gt;
                    Dim ltr As LayerTableRecord = DirectCast(tr.GetObject(layerId, OpenMode.ForWrite), LayerTableRecord)&lt;BR /&gt;
                    'laagkleur instellen&lt;BR /&gt;
                    ltr.Color = Color.FromColorIndex(ColorMethod.ByLayer, strucNewLayer.col.ColorIndex) '/strucNewLayer.col&lt;BR /&gt;
                    'linetype er aan koppelen&lt;BR /&gt;
                    ltr.LinetypeObjectId = GetLineTypeId(strucNewLayer.LineType)&lt;BR /&gt;
                    'visible instellen               &lt;BR /&gt;
                    ltr.IsOff = Not (strucNewLayer.Visible)&lt;BR /&gt;
                    'isPlottable instellen &lt;BR /&gt;
                    ltr.IsPlottable = strucNewLayer.IsPlottable&lt;BR /&gt;
                    'Locked instellen&lt;BR /&gt;
                    ltr.IsLocked = strucNewLayer.IsLocked&lt;BR /&gt;
                    'Frozen instellen&lt;BR /&gt;
                    ltr.IsFrozen = False&lt;BR /&gt;
                Else&lt;BR /&gt;
                    'Laag aanmaken&lt;BR /&gt;
                    Dim ltr As LayerTableRecord = New LayerTableRecord()&lt;BR /&gt;
                    'laagnaam instellen&lt;BR /&gt;
                    ltr.Name = strucNewLayer.Name&lt;BR /&gt;
                    'laagkleur instellen&lt;BR /&gt;
                    ltr.Color = Color.FromColorIndex(ColorMethod.ByLayer, strucNewLayer.col.ColorIndex) '/strucNewLayer.col&lt;BR /&gt;
                    'linetype er aan koppelen&lt;BR /&gt;
                    ltr.LinetypeObjectId = GetLineTypeId(strucNewLayer.LineType)&lt;BR /&gt;
                    'visible instellen               &lt;BR /&gt;
                    ltr.IsOff = Not (strucNewLayer.Visible)&lt;BR /&gt;
                    'isPlottable instellen &lt;BR /&gt;
                    ltr.IsPlottable = strucNewLayer.IsPlottable&lt;BR /&gt;
                    'Locked instellen&lt;BR /&gt;
                    ltr.IsLocked = strucNewLayer.IsLocked&lt;BR /&gt;
                    'Frozen instellen&lt;BR /&gt;
                    ltr.IsFrozen = False&lt;BR /&gt;
                    'laag toevoegen&lt;BR /&gt;
                    Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForWrite), LayerTable)&lt;BR /&gt;
                    layerId = lt.Add(ltr)&lt;BR /&gt;
                    tr.AddNewlyCreatedDBObject(ltr, True)&lt;BR /&gt;
                End If&lt;BR /&gt;
                tr.Commit()&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
                tr.Dispose()&lt;BR /&gt;
                layerId = Nothing&lt;BR /&gt;
            End Try&lt;BR /&gt;
        End Using&lt;BR /&gt;
        'laagId teruggeven&lt;BR /&gt;
        Return layerId&lt;BR /&gt;
&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
The code itself is working, when executed from an other place. In this case this function gives the error in the statement:&lt;BR /&gt;
Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForWrite), LayerTable)&lt;BR /&gt;
The reported error is "locked database".&lt;BR /&gt;
The switching of the database in the handler doesn't go well.&lt;BR /&gt;
&lt;BR /&gt;
Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Gerard van der Sel&lt;/SELG&gt;</description>
      <pubDate>Mon, 25 Feb 2008 17:42:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188106#M75443</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-25T17:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188107#M75444</link>
      <description>Hi Selg,&lt;BR /&gt;
&lt;BR /&gt;
Maybe you'll have better luck with the "documentActivated" event. &lt;BR /&gt;
&lt;BR /&gt;
I use the documentActivated to retrieve the various styles and blocks of a drawing.&lt;BR /&gt;
&lt;BR /&gt;
You should consider creating a class to manage the MDI.&lt;BR /&gt;
and create You're own pre-document class.&lt;BR /&gt;
I believe in the help sections of the ObjectARX SDK there some tips to consider.&lt;BR /&gt;
&lt;BR /&gt;
ps. looking at you're first post: I think you're AddHandler is wrong: shouldn't it be:&lt;BR /&gt;
AddHandler Application.DocumentManager.DocumentBecameCurrent, AddressOf SwitchStart ????&lt;BR /&gt;
&lt;BR /&gt;
A. Caddie.&lt;BR /&gt;
AutoCAD2008, VS2005, WinXP pro sp2.</description>
      <pubDate>Mon, 25 Feb 2008 18:15:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188107#M75444</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-25T18:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188108#M75445</link>
      <description>&amp;gt;&amp;gt; Maybe you'll have better luck with the "documentActivated" event. &lt;BR /&gt;
&lt;BR /&gt;
No, actually he'll have worse luck with that.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;CADDIE75&gt; wrote in message news:5857622@discussion.autodesk.com...&lt;BR /&gt;
Hi Selg,&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I use the documentActivated to retrieve the various styles and blocks of a drawing.&lt;BR /&gt;
&lt;BR /&gt;
You should consider creating a class to manage the MDI.&lt;BR /&gt;
and create You're own pre-document class.&lt;BR /&gt;
I believe in the help sections of the ObjectARX SDK there some tips to consider.&lt;BR /&gt;
&lt;BR /&gt;
ps. looking at you're first post: I think you're AddHandler is wrong: shouldn't it be:&lt;BR /&gt;
AddHandler Application.DocumentManager.DocumentBecameCurrent, AddressOf SwitchStart ????&lt;BR /&gt;
&lt;BR /&gt;
A. Caddie.&lt;BR /&gt;
AutoCAD2008, VS2005, WinXP pro sp2.&lt;/CADDIE75&gt;</description>
      <pubDate>Mon, 25 Feb 2008 22:56:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188108#M75445</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-25T22:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188109#M75446</link>
      <description>Process description:&lt;BR /&gt;
&lt;BR /&gt;
I have started a dot net program with drawing1. When I load a new drawing2 I need to check if some default layers are present. If they are not present i need to create them. The layers must be present, because the block i have to insert rely on those layers.&lt;BR /&gt;
&lt;BR /&gt;
In the "documentbecamecurrent" event is fired at all the situations i want to catch.&lt;BR /&gt;
&lt;BR /&gt;
Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Gerard van der Sel</description>
      <pubDate>Tue, 26 Feb 2008 07:20:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188109#M75446</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-26T07:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188110#M75447</link>
      <description>Depends on wath you imports:&lt;BR /&gt;
"Imports Autodesk.AutoCAD.ApplicationServices.Application" then you don't need Application.&lt;BR /&gt;
"Imports Autodesk.AutoCAD.ApplicationServices" you need the application first.</description>
      <pubDate>Tue, 26 Feb 2008 07:25:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188110#M75447</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-26T07:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188111#M75448</link>
      <description>Is your code inserting the block?&lt;BR /&gt;
&lt;BR /&gt;
If it is, why not create the layers just before you insert the block you have to insert? &lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;SELG&gt; wrote in message news:5858189@discussion.autodesk.com...&lt;BR /&gt;
Process description:&lt;BR /&gt;
&lt;BR /&gt;
I have started a dot net program with drawing1. When I load a new drawing2 I need to check if some default layers are present. If they are not present i need to create them. The layers must be present, because the block i have to insert rely on those layers.&lt;BR /&gt;
&lt;BR /&gt;
In the "documentbecamecurrent" event is fired at all the situations i want to catch.&lt;BR /&gt;
&lt;BR /&gt;
Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Gerard van der Sel&lt;/SELG&gt;</description>
      <pubDate>Tue, 26 Feb 2008 11:46:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188111#M75448</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-26T11:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: changing drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188112#M75449</link>
      <description>The code is inserting the blocks.  So making the layers while inserting the blocks is an option. But in our firm all layers are made. At the end is looked if a layer is empty and then removed.&lt;BR /&gt;
&lt;BR /&gt;
I reconsidered what I want. And I noticed I have made an error. If I switch to a drawing it doesn't have to be this sort of drawing. It could be an other type, in which case the wrong layers are inserted. So only switching of database and editor is enough. This is working, so now only for my own understanding of AutoCAD it is necessary to know what went wrong.&lt;BR /&gt;
&lt;BR /&gt;
Greetings,&lt;BR /&gt;
&lt;BR /&gt;
Gerard.</description>
      <pubDate>Tue, 26 Feb 2008 14:47:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/changing-drawing/m-p/2188112#M75449</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-02-26T14:47:38Z</dc:date>
    </item>
  </channel>
</rss>

