Author Topic: Troubles with .png image in layout - border appearing  (Read 1814 times)

0 Members and 1 Guest are viewing this topic.

Proctor

  • Guest
Troubles with .png image in layout - border appearing
« on: June 11, 2013, 05:22:11 PM »
Hello: I'm currently developing with autocad 2014 and .net api.

I have a template file that I've attached an image file in the layout using command imageattach. I was careful to set imageframe to 0 so that it would not place a border around it. I saved the template.

My application contains a command that creates a copy of this template and places some additional verbage into it; after, it displays it for them to print as a .pdf.
The problem seems to be that during the process of creating the copy of the template, the border appears around the image. when I do imageframe, I see it's still set to 0, so not sure what's going on; however i do know that, if set the imageframe to 1 and then back to 0, it removes it.

I wanted to know if there's a way for me to programatically set the imageframe in my newly created copy of the template?

Here's the code I use to create it:

Code: [Select]

 Public Shared Function createLayoutFromTemplate(ByVal newLayoutName As String, ByVal dbTemplate As Database, ByVal templateLayoutName As String) As Layout
        Dim newLayout As Layout
        Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
        Using tr As Transaction = db.TransactionManager.StartTransaction()
            newLayout = tr.GetObject(LayoutManager.Current().CreateLayout(newLayoutName), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
            Using tr2 As Transaction = dbTemplate.TransactionManager.StartTransaction()
                Dim lytDict As DBDictionary = tr2.GetObject(dbTemplate.LayoutDictionaryId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
                'Make sure the layout existes in the template database

                If Not lytDict.Contains(templateLayoutName) Then
                    Return Nothing
                End If

                Dim templateLayout As Layout = tr2.GetObject(lytDict.GetAt(templateLayoutName), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)

                newLayout.CopyFrom(templateLayout)
                Dim blkTableRec As BlockTableRecord = tr2.GetObject(templateLayout.BlockTableRecordId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
                Dim objIdCol As New ObjectIdCollection()
                For Each objId As ObjectId In blkTableRec
                    objIdCol.Add(objId)
                Next
                db.WblockCloneObjects(objIdCol, newLayout.BlockTableRecordId, New IdMapping(), DuplicateRecordCloning.MangleName, False)

                Dim newLayoutid As ObjectId = newLayout.ObjectId
                Dim plotSet As PlotSettings = New PlotSettings(False)
                plotSet = CType(tr.GetObject(newLayoutid, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, False, False), PlotSettings)

                Dim oPSVal As PlotSettingsValidator = PlotSettingsValidator.Current
                oPSVal.SetZoomToPaperOnUpdate(plotSet, True)

            End Using
            tr.Commit()
        End Using
        Return newLayout

    End Function


thank you for your help on this,
Proctor

Proctor

  • Guest
Re: Troubles with .png image in layout - border appearing
« Reply #1 on: June 14, 2013, 10:47:31 AM »
Hello: I have an adn account and was provided this solution from Balaji:

Code: [Select]
<<<
Application.SetSystemVariable("IMAGEFRAME", 0);
>>>


It is now working great.

thanks,
Proctor