.NET

Reply
*Expert Elite*
1,286 Posts
37 Kudos
Registered: ‎06-21-2004
Post 11 of 17

Re: AutoCAD Commands from vb.net 2010

03-26-2012 10:46 AM in reply to: vbNinja

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.

 

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
Valued Mentor
376 Posts
20 Kudos
Registered: ‎07-29-2008
Post 12 of 17

Re: AutoCAD Commands from vb.net 2010

03-26-2012 10:47 AM in reply to: vbNinja

What  namespaces have you imported? Is this a standalone EXE application? 

 

*Expert Elite*
1,286 Posts
37 Kudos
Registered: ‎06-21-2004
Post 13 of 17

Re: AutoCAD Commands from vb.net 2010

03-26-2012 10:50 AM in reply to: Mike.Wohletz

the above code won't work for a stand alone exe.

 

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
Contributor
21 Posts
0 Kudos
Registered: ‎03-18-2012
Post 14 of 17

Re: AutoCAD Commands from vb.net 2010

03-26-2012 11:13 AM in reply to: Mike.Wohletz

Hi

I have the following imports:

Imports System
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop

 

And yes this is a standalone EXE Application

 

Contributor
21 Posts
0 Kudos
Registered: ‎03-18-2012
Post 15 of 17

Re: AutoCAD Commands from vb.net 2010

03-26-2012 11:14 AM in reply to: Mike.Wohletz

Hi

I have the following imports:

Imports System
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop

 

And yes this is a standalone EXE application

 

Valued Mentor
376 Posts
20 Kudos
Registered: ‎07-29-2008
Post 16 of 17

Re: AutoCAD Commands from vb.net 2010

03-27-2012 06:04 AM in reply to: vbNinja

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(oLayerName)
            oLayer.color = oColor
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

 

Contributor
21 Posts
0 Kudos
Registered: ‎03-18-2012
Post 17 of 17

Re: AutoCAD Commands from vb.net 2010

03-27-2012 10:01 AM in reply to: Mike.Wohletz

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post