.NET

Reply
*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 11 of 17 (275 Views)

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
Mike.Wohletz
Posts: 375
Registered: ‎07-29-2008
Message 12 of 17 (272 Views)

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*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 13 of 17 (268 Views)

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
vbNinja
Posts: 21
Registered: ‎03-18-2012
Message 14 of 17 (261 Views)

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
vbNinja
Posts: 21
Registered: ‎03-18-2012
Message 15 of 17 (260 Views)

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
Mike.Wohletz
Posts: 375
Registered: ‎07-29-2008
Message 16 of 17 (241 Views)

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
vbNinja
Posts: 21
Registered: ‎03-18-2012
Message 17 of 17 (232 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community