Add a DWF Underlay

Add a DWF Underlay

Anonymous
Not applicable
565 Views
2 Replies
Message 1 of 3

Add a DWF Underlay

Anonymous
Not applicable
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
0 Likes
566 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
The attached file has code I have used to do this...
0 Likes
Message 3 of 3

Anonymous
Not applicable
jejamesNC,

Thanks for your help, works perfectly!
Greetings
0 Likes