.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: AutoCAD Commands from vb.net 2010
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Add these lines to the top of the class
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Colors
and add the reference to
acdbmgr.dll
acmgd.dll
and set copy local to false.

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
Re: AutoCAD Commands from vb.net 2010
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
What namespaces have you imported? Is this a standalone EXE application?
Re: AutoCAD Commands from vb.net 2010
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
the above code won't work for a stand alone exe.

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
Re: AutoCAD Commands from vb.net 2010
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi
I have the following imports:
Imports System
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop
And yes this is a standalone EXE Application
Re: AutoCAD Commands from vb.net 2010
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi
I have the following imports:
Imports System
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop
And yes this is a standalone EXE application
Re: AutoCAD Commands from vb.net 2010
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try something like this to set the layer colors:
Private Sub WorkingWithAutoCAD()
' we can set the color of one layer or current by:
acSetLayerColor(AcColor.acYellow)
'or
'set them all to green
For Each oLayer As AcadLayer In ThisApplication.ActiveDocument.Layers
acSetLayerColor(AcColor.acGreen, oLayer)
Next
' or set the OB layer to red and see if it happened calling by name
Dim Rval As Boolean = acSetLayerColorByName(AcColor.acRed, "OB")
End Sub Private Function acSetLayerColor(ByVal oColor As AcColor, Optional ByVal oLayer As AcadLayer = Nothing) As Boolean
Try
If oLayer Is Nothing Then 'we will look at the current layer
oLayer = ThisApplication.ActiveDocument.ActiveLayer
End If
oLayer.color = oColor
Return True
Catch ex As Exception
Return False
End Try
End Function
Private Function acSetLayerColorByName(ByVal oColor As AcColor, ByVal oLayerName As String) As Boolean
Try
Dim oLayer As AcadLayer = ThisApplication.ActiveDocument.Layers.Item(oLayerN ame)
oLayer.color = oColor
Return True
Catch ex As Exception
Return False
End Try
End Function
Re: AutoCAD Commands from vb.net 2010
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi
Your suggestions worked after I added a reference to acdbmgd.dll and acdmgd.dll and imported these namespaces:
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Colors
Thank you all for your help.
Best regards


