Hi,
We have a VB application which was written with AutoCAD Map 2008 version.
We now need to re-write the entire application with AutoCAD Map 3D in VB.NET
Can anybody suggest some good specs/pointer?
And the way to do it...
Thanks
It is very difficult to give much useful opinions/suggestions without knowing more details on what you have and you you want to do.
What kind of VB application do you have? is it an external EXE app, or it is VBA code running inside Acad, or it is VB ActiveX DLL project that is loaded into AutoCAD via VBA? What the application does?
When you want to rewrite it with VB.NET, are you going to do it as external EXE app? or if you want to make it DLL project, then do you want to use COM API, or .NET API (AutoCAD .NET API and/or Map .NET API)?
Norman Yuan
We have Vb 6 ActiveX dll applicatio which we want to convert to VB.NET 2008 DLL.
The application works with drawing files where we can add spaces to the floor of a building.
We can delete spaces as well.
When we want to convert to VB.NET 2008 DLL, we want to use .NET API (AutoCAD map 3D .NET API)
If you have .NET development experience, I am sure you know VB6 and VB.NET are very different other than their similar syntex. In most cases, there is no way to convert a VB6 project to a sound, workable VB.NET project.
Also, if you intend to use AutoCAD .NET API, then again, it is very different from AutoCAD COM API.
These two factors guarantees that whatever you have done in the VB6 project has to be rewritten with new API (AutoCAD .NET API) and new programming paradigm (.NET).
You can get started with AutoCAD .NET Programming labs, provided by Autodesk, or works on .NET code samples fond in ObjectARX SDK, or check this out:
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html
You may also want to visit and post your question in Autodesk Discussion Group -> AutoCAD -> AutoCAD Customization -> .NET forum, in regarding of generic AutoCAD .NET issue (other than specific AutoCAD Map programming issue).
Norman Yuan
I have created SDF using a dwg file in AutoCAD Map 3D 2012.
But I am not able to open the SDF file as I don't have a tool to open it.
Could you please suggest a tool to open it so that I can view the features & the layers that are embedded into it?
Could you please tell me the link from where I can download such tool?
Hi,
>> But I am not able to open the SDF file as I don't have a tool to open it.
Joke? 😉
You have Map3D, why don't you open the SDF with your Map3D then?
You can import it with _MAPIMPORT, you can reference it with _MAPCONNECT.
- alfred -
I am developing a project in VB.NET with AutoCAD Map 3D 2012.
I am opening a dwg file & want to know the layers that are present in the dwg file & then want to process those layers as per the requirement.
I tried to use AcMapMap.GetCurrentMap()
but it is failing, there is no such AcMapMap in AutoCAD Map 3D 2012.
Could you please tell me the way how should I know the name of the dwg file that I m opening & the layers that are present in the file?
Hi,
what references have you set within your project? I have referenced these dll's
...to get this running:
Imports Autodesk.AutoCAD Imports Autodesk.Gis.Map Imports OSGeo.MapGuide Public Class cFdoTools <Autodesk.AutoCAD.Runtime.CommandMethod("myTools_getFdoLayers")> _ Public Shared Sub getFdoLayers() Dim tLoadedFdoLayer As String = "" Try Dim tCurrentMap As Platform.AcMapMap = Platform.AcMapMap.GetCurrentMap() If (tCurrentMap IsNot Nothing) AndAlso (tCurrentMap.GetLayers IsNot Nothing) Then Dim tLayerColl As MgLayerCollection = tCurrentMap.GetLayers If (tLayerColl IsNot Nothing) AndAlso (tLayerColl.Count > 0) Then For Each tLayer As MgLayerBase In tLayerColl tLoadedFdoLayer &= tLayer.Name & vbNewLine Next End If End If Call MsgBox("Loaded Fdo-Layers: " & vbNewLine & tLoadedFdoLayer) Catch ex As Exception Call MsgBox("<Your ErrMsg>") End Try End Sub End Class
HTH, - alfred -
You asked me to add a reference as
Autodesk.Map.Platform.dll
But I don't have any such dll present in the AutoCAD install folder as well as ARX folder.
Could you please where would I get these dlls?
I am using AutoCAD Map 3D 2012.
Here I get Map object as Autodesk.Gis.Map.
But I am not able to find Platform in Gis.Map
Hi,
>> You asked me to add a reference as Autodesk.Map.Platform.dll
>> But I don't have any such dll
I have it in my installation-folder C:\Program Files\Autodesk\AutoCAD Civil 3D 2012 (you will have a Map-directory instead of my Civil one, but the file should be there.
- alfred -
Hi
I have a requirement which says, I have to open a dwg file, where I have to select some few polylines and then the selected polylines should be deleted.
I am able to select objects in the dwg file, but not able to delete it.
I am using AutoCAD Map 3D 2012 and VB.NET.
Here I am pasting part of the code that I am having as of now.
Dim acDocMgr As DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Dim acDoc As Document = acDocMgr.MdiActiveDocument
'Get the selected objects in the drawing area
Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection()
MsgBox(acSSPrompt.Status)
'If the prompt Status is OK, the objects are selected
If acSSPrompt.Status = PromptStatus.OK Then
MsgBox("OK")
'Selection Set for the selected objects
Dim acSSet As SelectionSet = acSSPrompt.Value
For Each acSSObj As SelectedObject In acSSet
Dim myMap As New Autodesk.AutoCAD.DatabaseServices.IdMapping
Dim myObjs As New Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection
If Not IsDBNull(acSSObj) Then
'Open the selected object for READ
Using trans As Transaction = acDoc.Database.TransactionManager.StartTransaction()
Using lock As DocumentLock = acDoc.LockDocument
Dim acEnt As Entity = DirectCast(trans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite), Entity)
acEnt.UpgradeOpen()
acEnt.Erase()
End Using
End Using
End If
Next
Hi,
why do you add your new question to an existing thread? For new questions please create new threads.
And to your code: you haven't commited the transaction 😉
- alfred -
Sorry for maintaining the same thread
I will open a new one
And I have committed the transaction, here I put just a part of the code.
Hi
I have a requirement which says, I have to open a dwg file, where I have to select some few polylines and then the selected polylines should be deleted.
I am able to select objects in the dwg file, but not able to delete it.
I am using AutoCAD Map 3D 2012 and VB.NET.
Here I am pasting part of the code that I am having as of now.
Dim acDocMgr As DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Dim acDoc As Document = acDocMgr.MdiActiveDocument
'Get the selected objects in the drawing area
Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection()
MsgBox(acSSPrompt.Status)
'If the prompt Status is OK, the objects are selected
If acSSPrompt.Status = PromptStatus.OK Then
MsgBox("OK")
'Selection Set for the selected objects
Dim acSSet As SelectionSet = acSSPrompt.Value
For Each acSSObj As SelectedObject In acSSet
Dim myMap As New Autodesk.AutoCAD.DatabaseServices.IdMapping
Dim myObjs As New Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection
If Not IsDBNull(acSSObj) Then
'Open the selected object for READ
Using trans As Transaction = acDoc.Database.TransactionManager.StartTransaction()
Using lock As DocumentLock = acDoc.LockDocument
Dim acEnt As Entity = DirectCast(trans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite), Entity)
acEnt.UpgradeOpen()
acEnt.Erase()
End Using
End Using
trans.Commit()
End If
Next
Hi,
>> And I have committed the transaction, here I put just a part of the code.
No, with End Using you disposed this transaction, and after acEnt.Erase and before End Using I see not trans.Commit
It does not depend then on any lines after that snippet you showed here.
One more tip: if you opened an object with .ForWrite you don't need the .UpgradeOpen.
- alfred -
Hi,
now you are commiting the transaction when it is already disposed ... sorry, but when you run this code you should get exceptions (hope you watch them in VS).
- alfred -
I am confused whether I should commit the transaction or not, as I have already disposed the entity.
Edited by
Discussion_Admin
I also merged the two topics into one
Hi,
>> I am confused whether I should commit the transaction or not, as I have already disposed the entity.
You have first to commit the transaction and then dispose it.
Using trans As Transaction = acDoc.Database.TransactionManager.StartTransaction()
'...do your work, modify your object
trans.Commit() 'now save the modifications to the database
End Using 'this disposes the transaction / free up it's ressources
HTH, - alfred -
I modified the code for transaction.
I tried to use Light Weight Polyline for deleting the polylines fromt the dwg file.
I have kept that code in bold letter below.
But it gives an error that there is no object as AcadLWPolyline for AutoCAD Map 3D 2012.
I am not not able to proceed on how to delete the polyline.
Please help me out.
Dim acDocMgr As DocumentCollection =Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Dim acDoc As Document = acDocMgr.MdiActiveDocument
'Get the selected objects in the drawing area
Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection()
'If the prompt Status is OK, the objects are selected
If acSSPrompt.Status = PromptStatus.OK Then
'Selection Set for the selected objects
Dim acSSet As SelectionSet = acSSPrompt.Value
'Step through the objects in the Selection Set
For Each acSSObj As SelectedObject In acSSet
Dim myMap As New Autodesk.AutoCAD.DatabaseServices.IdMapping
Dim myObjs As New Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection
'Check to make sure a valid object was returned
If Not IsDBNull(acSSObj) Then
'Open the selected object for READ
Using trans As Transaction = acDoc.Database.TransactionManager.StartTransaction()
Using lock As DocumentLock = acDoc.LockDocument
'Dim acEnt As Entity = DirectCast(trans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite), Entity)
Dim entities As New ObjectIdCollection(acSSPrompt.Value.GetObjectIds())
For Each oid As ObjectId In entities
If oid.ObjectClass.Name.Equals("AcDbPolyline") Then
Dim pl As Polyline = TryCast(trans.GetObject(oid, OpenMode.ForWrite), Polyline)
Dim acadPl As AcadLWPolyline = TryCast(pl.AcadObject, AcadLWPolyline)
acadPl.Erase()
End If
Next
trans.Commit() --- Here I commited the transaction & later it was disposed
End Using
End Using
End If
Next
Hi,
you can't cast a Polyline to a AcadLwPolyline, that's the same as trying to cast a Circle to a Line, they are totally different objects.
If you only want to delete specific objects then use the filter-methods during the selection of objects or at least verify the objecttype of the object to delete.
- alfred -