Copy a layout with its entities from one drawing to another

By Virupaksha Aithal

One simply approach to copy a layout with its entities is use “SendCommand”. Below code shows the procedure where code using command line implementation of layout (layout command) coping.

_
        Public Shared Sub ImportLayout()
 
            Dim fd As Object = _
                        Application.GetSystemVariable("FILEDIA")
            Application.SetSystemVariable("FILEDIA", 0)
 
            Dim acadapp As Object = Application.AcadApplication
            'start layout command
            acadapp.ActiveDocument.SendCommand("-Layout" + vbCr)
            'say wants to import from tamplate
            acadapp.ActiveDocument.SendCommand("Template" + vbCr)
            'provide the file path
            acadapp.ActiveDocument.SendCommand("c:temptest.dwt" _
                                                            + vbCr)
            'provide the template name
            acadapp.ActiveDocument.SendCommand("TestLayout" + vbCr)
            Application.SetSystemVariable("FILEDIA", fd)
        End Sub

Comments

2 responses to “Copy a layout with its entities from one drawing to another”

  1. Ronald Avatar
    Ronald

    Hi Virupuksha,
    not really helpfull to use VBA interop Com – Objects which are not supplied any longer by Autodesk. There is also a real .NET solution for this issue possible.

  2. Hi Ronald,
    What do you mean by “not supplied any longer by Autodesk”? We still provide the COM Interop assemblies as part of the ObjectARX SDK. We just stopped installing them in the GAC as of AutoCAD 2013. You just need to reference the versions from the ObjectARX SDK and turn on type embedding for your project.
    Cheers,
    Stephen

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading