Message 1 of 3
Add a DWF Underlay
Not applicable
02-24-2010
06:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I´m develop a function in AutoCad Map 2010 to add a Dwf Underlay from an external file.
I've tried with the following code but it doesn't work
{code}
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Transaction tr = db.TransactionManager.StartTransaction();
//DWFDEFINITION
DwfDefinition dd = new DwfDefinition();
dd.SourceFileName = "C:\\nameFile.dwf";
dd.ItemName = "nameFile";
dd.Load("");
DBDictionary dict = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite);
dict.SetAt("nameFile - nameFile", dd);
// DWFREFERENCE
DwfReference dr = new DwfReference();
dr.DefinitionId = dd.ObjectId;
dr.Position = new Point3d(10.6134597527748, 12.566448809153, 0);
dr.Rotation = 1.0;
dr.ScaleFactors = new Scale3d(0.111529677577706, 0.111529677577706, 0.111529677577706);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
btr.AppendEntity(dr);
tr.AddNewlyCreatedDBObject(dr, true);
tr.Commit();
{code}
What am I doing wrong?
Why it doesn't work or how must I do it?
I'll appreciate any comment
I've tried with the following code but it doesn't work
{code}
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Transaction tr = db.TransactionManager.StartTransaction();
//DWFDEFINITION
DwfDefinition dd = new DwfDefinition();
dd.SourceFileName = "C:\\nameFile.dwf";
dd.ItemName = "nameFile";
dd.Load("");
DBDictionary dict = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite);
dict.SetAt("nameFile - nameFile", dd);
// DWFREFERENCE
DwfReference dr = new DwfReference();
dr.DefinitionId = dd.ObjectId;
dr.Position = new Point3d(10.6134597527748, 12.566448809153, 0);
dr.Rotation = 1.0;
dr.ScaleFactors = new Scale3d(0.111529677577706, 0.111529677577706, 0.111529677577706);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
btr.AppendEntity(dr);
tr.AddNewlyCreatedDBObject(dr, true);
tr.Commit();
{code}
What am I doing wrong?
Why it doesn't work or how must I do it?
I'll appreciate any comment