.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Programatically insert entities Real DWG

1 REPLY 1
Reply
Message 1 of 2
jbalapa
320 Views, 1 Reply

Programatically insert entities Real DWG

Hello All,

We trying to insert a Legend into our drawing after we run some hatch reports. When I try to insert it progrmatically it does not show. Can anyone tell me what we are doing wrong.

BlockTable bt1 = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr1 = (BlockTableRecord)tr.GetObject(bt1[BlockTableRecord.ModelSpace], OpenMode.ForWrite);


Point3d TopLeft=new Point3d(1402,242,0);
Point3d BottomLeft=new Point3d(1402,107,0);
Point3d TopRight=new Point3d(1462,242,0);
Point3d BottomRight=new Point3d(1462,107,0);

Line myLine = new Line(TopLeft, TopRight);
Line myLine1 = new Line(TopRight, BottomRight);
myLine.Color = Color.FromColor(System.Drawing.Color.White);
myLine.Thickness = 2000;
myLine1.Color = Color.FromColor(System.Drawing.Color.White);
myLine1.Thickness = 2000;


btr1.AppendEntity(myLine);
btr1.AppendEntity(myLine1);
tr.AddNewlyCreatedDBObject(myLine, true);
tr.AddNewlyCreatedDBObject(myLine1, true);



db.SaveAs(TempString, DwgVersion.AC1800);

Thanks in advance.

- Jay Balapa
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: jbalapa

Do you need to commit it to the transaction?
Under this line
tr.AddNewlyCreatedDBObject(myline1,true);
add this
tr.Commit();

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5607430@discussion.autodesk.com...
Hello All,

We trying to insert a Legend into our drawing after we run some hatch
reports. When I try to insert it progrmatically it does not show. Can anyone
tell me what we are doing wrong.

BlockTable bt1 = (BlockTable)tr.GetObject(db.BlockTableId,
OpenMode.ForRead);
BlockTableRecord btr1 =
(BlockTableRecord)tr.GetObject(bt1[BlockTableRecord.ModelSpace],
OpenMode.ForWrite);


Point3d TopLeft=new Point3d(1402,242,0);
Point3d BottomLeft=new Point3d(1402,107,0);
Point3d TopRight=new Point3d(1462,242,0);
Point3d BottomRight=new Point3d(1462,107,0);

Line myLine = new Line(TopLeft, TopRight);
Line myLine1 = new Line(TopRight, BottomRight);
myLine.Color = Color.FromColor(System.Drawing.Color.White);
myLine.Thickness = 2000;
myLine1.Color = Color.FromColor(System.Drawing.Color.White);
myLine1.Thickness = 2000;


btr1.AppendEntity(myLine);
btr1.AppendEntity(myLine1);
tr.AddNewlyCreatedDBObject(myLine, true);
tr.AddNewlyCreatedDBObject(myLine1, true);



db.SaveAs(TempString, DwgVersion.AC1800);

Thanks in advance.

- Jay Balapa

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost