Error in .NET concerning the Layer Property of a Solid 3D Object ???
in 3D Modeling
Hi all,
I am trying to change the Layer of a Solid3D sphere using following code :
[code]
// ODA
using Teigha.Runtime;
using Teigha.DatabaseServices;
using Teigha.Geometry;
// Bricsys
using Bricscad.ApplicationServices;
using Bricscad.Runtime;
using Bricscad.EditorInput;
namespace TestingLayer
{
public class Commands
{
[CommandMethod("testlay")]
public static void CreateSolidSphere()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Transaction tr = doc.TransactionManager.StartTransaction();
using (tr)
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
Solid3d s = new Solid3d();
s.CreateSphere(50);
s.Layer = "20";
btr.AppendEntity(s);
tr.AddNewlyCreatedDBObject(s, true);
tr.Commit();
}
}
}
}[/code]
The statement s.Layer = "20"; brings the error in the attached screenshot below
I use a .DWG with the Layer Name "20" and the Layer already created !
If i comment (deactivate ) the above statement the sphere gets created and no problems arise.
In AutoCAD the statement doesn't throw any errors and the sphere is changed to layer named "20"
I attach the .DWG as well.
Could anyone outhere check it out before I create a Bug-Support request !
Regards, Thanks
Konstantin
I am trying to change the Layer of a Solid3D sphere using following code :
[code]
// ODA
using Teigha.Runtime;
using Teigha.DatabaseServices;
using Teigha.Geometry;
// Bricsys
using Bricscad.ApplicationServices;
using Bricscad.Runtime;
using Bricscad.EditorInput;
namespace TestingLayer
{
public class Commands
{
[CommandMethod("testlay")]
public static void CreateSolidSphere()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Transaction tr = doc.TransactionManager.StartTransaction();
using (tr)
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
Solid3d s = new Solid3d();
s.CreateSphere(50);
s.Layer = "20";
btr.AppendEntity(s);
tr.AddNewlyCreatedDBObject(s, true);
tr.Commit();
}
}
}
}[/code]
The statement s.Layer = "20"; brings the error in the attached screenshot below
I use a .DWG with the Layer Name "20" and the Layer already created !
If i comment (deactivate ) the above statement the sphere gets created and no problems arise.
In AutoCAD the statement doesn't throw any errors and the sphere is changed to layer named "20"
I attach the .DWG as well.
Could anyone outhere check it out before I create a Bug-Support request !
Regards, Thanks
Konstantin
0
Comments
-
I attach the assemply to reproduce the error easily...! i hope0
-
Either add
s.SetDatabaseDefaults(db);
or move
s.Layer = "20";
after
btr.AppendEntity(s);
cheers
0 -
thanks a lot Daniel...both suggestions have worked !
It is interesting though, that none of them is needed in AutoCAD !
Greetings0 -
thanks a lot Daniel...both suggestions have worked !
It is interesting though, that none of them is needed in AutoCAD !
GreetingsGreat, glad it worked : )
Acad is doing a certain amount of handholding behind the scenes, whereas TD_MGD is a bit pickier. If you step back and think about it, there is a certain amount of ambiguity in assigning a layer to a new non database resident entity. Acad assumes you mean the working database whereas TD_MGD wants to know 'which' database in the case that the coder is working with multiple databases.
Cheers
0 -
Ja...I thought that it is something behind the scenes, something
having to do with a new and not yet database resident entity.
Thanks for explaining this...
Greetings0
This discussion has been closed.