.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

autocad map 3D insert Block error

1 REPLY 1
Reply
Message 1 of 2
Sgear
370 Views, 1 Reply

autocad map 3D insert Block error

Hi

I am try to insert Block into Layout in autocad map 3D 2014
but I get error if I try this in Autocad 2014 then it works well no error

 

can anyone help me please how I can fix this

 

Autodesk.AutoCAD.Runtime.Exception: eNotApplicable
at Autodesk.AutoCAD.EditorInput.Editor.UpdateTiledViewportsFromDatabase()

 

 

Namespace extracommands

      <CommandMethod("FRAME (A4)")> _
        Public Shared Sub setjainnramman()
               ApplicationMenu.frameA4()
           End Sub


 Public Class ApplicationMenu

        Public Shared Sub frameA4()
            Dim doc As Document = _
                         Application.DocumentManager.MdiActiveDocument
            Dim db As Database = _
                        doc.Database
            Dim tr As Transaction = _
                            db.TransactionManager.StartTransaction()

            Dim ed As Editor = doc.Editor

            Using tr
                Try
                    Dim layoutMgr1 As LayoutManager = _
                                            LayoutManager.Current
                    Dim layoutId As ObjectId = _
                                layoutMgr1.GetLayoutId("A4")
                    If layoutId.IsNull = True Then
                        tr.Abort()
                        Return
                    End If

                    Dim layoutObj As Layout = _
                                tr.GetObject(layoutId, _
                                            OpenMode.ForWrite, False)
                    Dim layId As ObjectId = _
                        layoutObj.BlockTableRecordId
                    Dim layoutBtr As BlockTableRecord = _
                                    tr.GetObject(layId, _
                                            OpenMode.ForWrite, True)

                    Dim id As ObjectId = Nothing
                    Dim bt As BlockTable = _
                                    tr.GetObject(db.BlockTableId, _
                                        OpenMode.ForRead, True)

                    Dim blkName As String = "A4-frame"

                    If bt.Has(blkName) Then
                        id = bt.Item(blkName)
                        Dim insPt As New Point3d(0.7566, 0.6746, 0)
                        Dim bref As BlockReference = _
                                    New BlockReference(insPt, id)
                        layoutBtr.AppendEntity(bref)

                        tr.AddNewlyCreatedDBObject(bref, True)
                        tr.Commit()
                    Else
                        tr.Abort()
                    End If

                Catch ex As System.Exception
                    ed.WriteMessage(ex.ToString())
                End Try
            End Using
        End Sub
   End Class

End Namespace

 

Regards

sgear

1 REPLY 1
Message 2 of 2
Alfred.NESWADBA
in reply to: Sgear

Hi,

 

try to lock the document before starting the transaction (and dispose it after "End Using" of the "tr").

To try the code I guess it's depending on the drawing you try to insert the block into (and if external the file "A4-frame" too), please upload this/them.

 

Have you installed the latest servicepack for Map3D 2014? (>>>click<<<).

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost