Jump to content

assign color to line vb.net with interop


geogiac

Recommended Posts

Hi i am desperately trying to change the color of a line ......

i use visual studio and autocad 2009 in an out of process environment

 

right now i use this code to create a line

 

it works fine (i did not quote the code to assign the coordinates to the point)

 

but now i can not seem to be able to change the color of the object (acadline) i created.......

 

any help!!!!!?!??

 

'*******

Imports Autodesk.AutoCAD.Interop.acaddocumentclass

Imports autodesk.AutoCAD.Interop.Common

Module CONNETTI_AUTOCAD

 

Public acad As Autodesk.AutoCAD.Interop.AcadApplication

Public acaddoc As Autodesk.AutoCAD.Interop.AcadDocument

PublicSub CONNETTI_AUTOCAD_COM()

Dim linea As AcadLine

acad = GetObject(, "AUTOCAD.APPLICATION")

acaddoc = acad.activeDocument

 

linea = acaddoc.ModelSpace.AddLine(start, finish)

'**********

Link to comment
Share on other sites

Hi

 

While you're using the COM API, you ca look at ACtiveX and VBA Reference in the AutoCAD Developer's Guide.

 

For the index colors you can use the Color Property which value have to be an integer between 0 and 256 or one of the following constants:

acByBlock(0)

acByLayer (256)

acRed (1)

acYellow (2)

acGreen (3)

acCyan (4)

acBlue (5)

acMagenta (6)

acWhite (7)

 

I'm not very comfortable with VB syntax, but it should be something like this

 

linea.Color = acRed or linea.Color = 1

 

For 'true colors' you have to use an AcadAcCmColor object :

 

Dim col As New AcadAcCmColor

col.Red = 28

col.Green = 111

col.Blue = 225

linea.TrueColor = col

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...