Quantcast
Viewing all articles
Browse latest Browse all 14319

Background image & WHIP

I've found a way to put an image as the background:

 

[CommandMethod("BG")]
public void Bg()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    using (Transaction tr = db.TransactionManager.StartTransaction())
    {
        var imgBg = new ImageBackground
        {
            ImageFileName = @"...",
            FitToScreen = true
        };
        var bgDict = (DBDictionary)tr.GetObject(Background.GetBackgroundDictionaryId(db, true), OpenMode.ForWrite);
        bgDict.SetAt(Path.GetFileNameWithoutExtension(imgBg.ImageFileName), imgBg);
        tr.AddNewlyCreatedDBObject(imgBg, true);
        var vt = (ViewportTable)tr.GetObject(db.ViewportTableId, OpenMode.ForRead);
        var vtr = (ViewportTableRecord)tr.GetObject(vt[SymbolUtilityServices.ViewportActiveName], 
            OpenMode.ForWrite);
        vtr.Background = imgBg.Id;
        tr.Commit();
    }
}

 It works with AGS (3D visual style), but not with WHIP (2D Wireframe visual style). The image is not displayed.

 

Someone know how to make this work with WHIP?

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 14319

Trending Articles