<?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 Autodesk.AutoCAD.Runtime.Exception: 'eNoDatabase' in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-runtime-exception-enodatabase/m-p/11538810#M11045</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I am writing a C#.NET program that interacts with AutoCAD through the AutoCAD .NET API.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The program changes the objects from one layer to another, if the layer does not exist it creates a new one with some parameters that are passed through a document. To open the document we use the ReadDwgFile method. We open the document in a hidden way, so that it does not run. I have tried to change the transparency of the document that I have active, and it does it without problems, it gives me an error when I do it in a file that I do not have active. So I think the error is there. Is there a way to change the transparency of a layer whose file I have opened with the&amp;nbsp;ReadDwgFile method?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;SPAN class=""&gt;The program gives an error when I want to change the transparency of the layer of a document that I do not have open.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                using (Database destinationDatabase = new Database(false, true))
                {
                    destinationDatabase.ReadDwgFile(file.FullName, FileShare.ReadWrite, true, "");


                    using (Transaction destinationTransaction = destinationDatabase.TransactionManager.StartTransaction())
                     {
                      BlockTable bt = (BlockTable)destinationTransaction.GetObject(destinationDatabase.BlockTableId, OpenMode.ForWrite);
                        BlockTableRecord record = destinationTransaction.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                        LayerTable layertable;
                        layertable = destinationTransaction.GetObject(destinationDatabase.LayerTableId,OpenMode.ForWrite) as LayerTable;
                        foreach (ObjectId ob in record)
                        {
                            Entity eo = (Entity)ob.GetObject(OpenMode.ForWrite);
                            if (DicLayer.Keys.Contains(eo.Layer))
                            {
                                ClassLayer layer = DicLayer[eo.Layer];

                                if (!layertable.Has(layer.LayerNewName))
                                {
                                    using (LayerTableRecord layertablerecord = new LayerTableRecord())
                                    {

                                        Type enumType = typeof(LineWeight);
                                        System.Reflection.FieldInfo[] fieldInfos = enumType.GetFields();
                                        Dictionary&amp;lt;string, FieldInfo&amp;gt; lineWeigthDict = new Dictionary&amp;lt;string, FieldInfo&amp;gt;();
                                        foreach (System.Reflection.FieldInfo fieldInfo in fieldInfos)
                                        {
                                            lineWeigthDict.Add(fieldInfo.Name, fieldInfo);
                                        }
                                        LinetypeTable acLinTbl;
                                        acLinTbl = destinationTransaction.GetObject(destinationDatabase.LinetypeTableId,
                                                                        OpenMode.ForWrite) as LinetypeTable;
                                        // Line Weight
                                        string lineWeigtName = "";
                                        String lwn = layer.LineWeight;
                                        switch (lwn)
                                        {
                                            case "Default":
                                                lineWeigtName = "ByLineWeightDefault";
                                                break;
                                            default:
                                                 lineWeigtName = "LineWeight" + layer.LineWeight;
                                                break;

                                        }
                                        
                                        LineWeight lineWeight = (LineWeight)lineWeigthDict[lineWeigtName].GetValue(null);
                                      
                                        





                                        layertablerecord.Color = Color.FromColorIndex(ColorMethod.ByAci, short.Parse(layer.Color.ToString()));
                                        layertablerecord.Name = layer.LayerNewName;
                                        layertablerecord.LineWeight = lineWeight;
                                        layertablerecord.LinetypeObjectId = acLinTbl[layer.LineType];
                                        Byte alpha = (Byte)(255 * (100 - Int32.Parse(layer.Transpaerncy)) / 100);
                                        Transparency transparency = new Transparency(alpha);
                                        layertablerecord.Transparency = transparency;







                                        // Upgrade the Layer table for write
                                        destinationTransaction.GetObject(destinationDatabase.LayerTableId, OpenMode.ForWrite);
                                                                             
                                        // Append the new layer to the Layer table and the transaction
                                        layertable.Add(layertablerecord);
                                        destinationTransaction.AddNewlyCreatedDBObject(layertablerecord, true);

                                    }
                                    eo.Layer = layer.LayerNewName;
                                }
                                else
                                {
                                    eo.Layer = layer.LayerNewName;
                                }

                            }




                        }



                        destinationTransaction.Commit();

                    }
                    destinationDatabase.RetainOriginalThumbnailBitmap = true;
                    destinationDatabase.SaveAs(file.FullName, true, DwgVersion.Current, null);


                }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Nov 2022 15:57:42 GMT</pubDate>
    <dc:creator>agomezfe</dc:creator>
    <dc:date>2022-11-08T15:57:42Z</dc:date>
    <item>
      <title>Autodesk.AutoCAD.Runtime.Exception: 'eNoDatabase'</title>
      <link>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-runtime-exception-enodatabase/m-p/11538810#M11045</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am writing a C#.NET program that interacts with AutoCAD through the AutoCAD .NET API.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The program changes the objects from one layer to another, if the layer does not exist it creates a new one with some parameters that are passed through a document. To open the document we use the ReadDwgFile method. We open the document in a hidden way, so that it does not run. I have tried to change the transparency of the document that I have active, and it does it without problems, it gives me an error when I do it in a file that I do not have active. So I think the error is there. Is there a way to change the transparency of a layer whose file I have opened with the&amp;nbsp;ReadDwgFile method?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;SPAN class=""&gt;The program gives an error when I want to change the transparency of the layer of a document that I do not have open.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                using (Database destinationDatabase = new Database(false, true))
                {
                    destinationDatabase.ReadDwgFile(file.FullName, FileShare.ReadWrite, true, "");


                    using (Transaction destinationTransaction = destinationDatabase.TransactionManager.StartTransaction())
                     {
                      BlockTable bt = (BlockTable)destinationTransaction.GetObject(destinationDatabase.BlockTableId, OpenMode.ForWrite);
                        BlockTableRecord record = destinationTransaction.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                        LayerTable layertable;
                        layertable = destinationTransaction.GetObject(destinationDatabase.LayerTableId,OpenMode.ForWrite) as LayerTable;
                        foreach (ObjectId ob in record)
                        {
                            Entity eo = (Entity)ob.GetObject(OpenMode.ForWrite);
                            if (DicLayer.Keys.Contains(eo.Layer))
                            {
                                ClassLayer layer = DicLayer[eo.Layer];

                                if (!layertable.Has(layer.LayerNewName))
                                {
                                    using (LayerTableRecord layertablerecord = new LayerTableRecord())
                                    {

                                        Type enumType = typeof(LineWeight);
                                        System.Reflection.FieldInfo[] fieldInfos = enumType.GetFields();
                                        Dictionary&amp;lt;string, FieldInfo&amp;gt; lineWeigthDict = new Dictionary&amp;lt;string, FieldInfo&amp;gt;();
                                        foreach (System.Reflection.FieldInfo fieldInfo in fieldInfos)
                                        {
                                            lineWeigthDict.Add(fieldInfo.Name, fieldInfo);
                                        }
                                        LinetypeTable acLinTbl;
                                        acLinTbl = destinationTransaction.GetObject(destinationDatabase.LinetypeTableId,
                                                                        OpenMode.ForWrite) as LinetypeTable;
                                        // Line Weight
                                        string lineWeigtName = "";
                                        String lwn = layer.LineWeight;
                                        switch (lwn)
                                        {
                                            case "Default":
                                                lineWeigtName = "ByLineWeightDefault";
                                                break;
                                            default:
                                                 lineWeigtName = "LineWeight" + layer.LineWeight;
                                                break;

                                        }
                                        
                                        LineWeight lineWeight = (LineWeight)lineWeigthDict[lineWeigtName].GetValue(null);
                                      
                                        





                                        layertablerecord.Color = Color.FromColorIndex(ColorMethod.ByAci, short.Parse(layer.Color.ToString()));
                                        layertablerecord.Name = layer.LayerNewName;
                                        layertablerecord.LineWeight = lineWeight;
                                        layertablerecord.LinetypeObjectId = acLinTbl[layer.LineType];
                                        Byte alpha = (Byte)(255 * (100 - Int32.Parse(layer.Transpaerncy)) / 100);
                                        Transparency transparency = new Transparency(alpha);
                                        layertablerecord.Transparency = transparency;







                                        // Upgrade the Layer table for write
                                        destinationTransaction.GetObject(destinationDatabase.LayerTableId, OpenMode.ForWrite);
                                                                             
                                        // Append the new layer to the Layer table and the transaction
                                        layertable.Add(layertablerecord);
                                        destinationTransaction.AddNewlyCreatedDBObject(layertablerecord, true);

                                    }
                                    eo.Layer = layer.LayerNewName;
                                }
                                else
                                {
                                    eo.Layer = layer.LayerNewName;
                                }

                            }




                        }



                        destinationTransaction.Commit();

                    }
                    destinationDatabase.RetainOriginalThumbnailBitmap = true;
                    destinationDatabase.SaveAs(file.FullName, true, DwgVersion.Current, null);


                }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 15:57:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-runtime-exception-enodatabase/m-p/11538810#M11045</guid>
      <dc:creator>agomezfe</dc:creator>
      <dc:date>2022-11-08T15:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk.AutoCAD.Runtime.Exception: 'eNoDatabase'</title>
      <link>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-runtime-exception-enodatabase/m-p/11544219#M11046</link>
      <description>&lt;P&gt;Can you try changing the transparency after you add the layertablerecord to the database?&lt;BR /&gt;Try changing the transparency on line 76.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 17:02:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-runtime-exception-enodatabase/m-p/11544219#M11046</guid>
      <dc:creator>WonkaPet</dc:creator>
      <dc:date>2022-11-10T17:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk.AutoCAD.Runtime.Exception: 'eNoDatabase'</title>
      <link>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-runtime-exception-enodatabase/m-p/11550324#M11047</link>
      <description>Thanks, the change has worked correctly for me.</description>
      <pubDate>Mon, 14 Nov 2022 08:00:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-runtime-exception-enodatabase/m-p/11550324#M11047</guid>
      <dc:creator>agomezfe</dc:creator>
      <dc:date>2022-11-14T08:00:17Z</dc:date>
    </item>
  </channel>
</rss>

