Community
Set Room = AcadApp.ActiveDocument.HandleToObject("22add")
This line fails with an error... everything works as it should up to this line.
"22add" is a known entity handle...
AcadApp.ActiveDocument.HandleToObject response with intellesence as it should. The error I get is... Run-time error '48': Error in loading DLL
Dim Room As AcadEntity
AcadApp.ActiveDocument.Activate
Set Room = AcadApp.ActiveDocument.HandleToObject("22add")
Try this code, it's working on A2010, I could not have other
version to test
Public Sub testHandleToObject() Dim appver As Object = TryCast(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD", "CurVer", Nothing), Object) If appver IsNot Nothing Then MsgBox("You have " + "Autocad.Application." + appver.ToString() + " installed") Else MsgBox("Out of luck, sorry, use your other code to get Application") End If Dim vernum As Integer = CInt(Math.Floor(Convert.ToDouble(appver.ToString().Substring(1), CultureInfo.InvariantCulture))) Dim progID As String = "Autocad.Application." & vernum.ToString() Dim AcadApp As AcadApplication = Nothing Try AcadApp = TryCast(Marshal.GetActiveObject(progID), AcadApplication) Catch MsgBox("Cannot create object of type """ & progID & """") Exit Sub End Try AcadApp.Visible = True MsgBox("Wait!...") Dim acdoc As AcadDocument = AcadApp.ActiveDocument Dim Room As Common.AcadEntity Dim oEnt As Object oEnt = AcadApp.ActiveDocument.HandleToObject("618") Room = TryCast(oEnt, Common.AcadEntity) If Room Is Nothing Then MsgBox("Object did not recognised, exit...") Return Else MsgBox(Room.ObjectName) If Room.ObjectName = "AcDbPolyline" Then Dim oPoly As Common.AcadLWPolyline oPoly = TryCast(Room, Common.AcadLWPolyline) If oPoly IsNot Nothing Then MsgBox("Area: " + oPoly.Area.ToString) End If End If End If End Sub