News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Color line

Started by casf2012, November 25, 2014, 09:42:40 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

casf2012

Hi,

How can i get the color of polyline or arc in vb6? (current color doesn't fit my needs)

Thanks in advance.

Best regards,
Carlos Ferreira

prl

Property Color As Long

Read/Write.

Description:
The Color property indicates the entity's color.

Example:



To build an RGB color from separate color components, you can do the following:

MyColor = RGB(DcRed, DcGreen, DcBlue)

DcEntity.Color = MyColor




casf2012

thanks for the help.


But i want to know what color is the line drawing for the user.

Because when i get entity.color i get an error.

best regards,
Carlos Ferreira

prl

Not sure I understand.  If the line is not yet drawn, a new line will be drawing with the current color.

QuoteProperty CurrentColor As Long

Read/Write.

Description:
The CurrentColor property indicates the current drawing color. The number is a long integer representing an RGB value. The lowest 8 bits represent the Red component, the next-lowest 8 bits represent the Green component, the next-lowest represent the Blue component, and the highest 8 bits are reserved. To read a color value into separate RGB components, you can do the following:

Dim MyColor As Long

Dim DcRed As Long

Dim DcGreen As Long

Dim DcBlue As Long

DcRed  = MyColor AND 255

DcGreen = (MyColor \ 256 ) AND 255

DcBlue = (MyColor \ 65536) AND 255

To build an RGB color from separate color components, you can do the following:

MyColor = RGB(DcRed, DcGreen, DcBlue)

Example:

' Assumes DcDoc is a valid DesignCAD.Document object

' save the old color, and set the current color to RGB values 128, 128, 0

Dim OldColor As Long

Dim NewColor As Long

Dim DcRed As Long

Dim DcBlue As Long

Dim DcGreen As Long

OldColor = DcDoc.CurrentColor

DcRed = 128

DcGreen = 128

DcBlue = 0

NewColor = RGB(DcRed, DcGreen, DcBlue)

DcDoc.CurrentColor = NewColor

prl

To go the other way,


Col = DcEntity.Color

Dim R as integer     
Dim G as integer     
Dim B as integer     

Sub FindRGB(Col As Long)     
R = &HFF& And Col     
G = (&HFF00& And Col ) \ 256     
B = (&HFF0000 And Col ) \ 65536     
End Sub 

Rob S

So, without fully understanding the macros above, I believe the original request was to find a way to draw a macro-produced entity in a specified color other than the current drawing color.

It appears from the above that this would only be possible by 4 step process:

- assign the "current" color to a variable

- set a new desired "current color"

- draw the new entity

- restore the "current color" back to original from the variable
User since forever

DrollTroll

#6
Basically, yes. Leaving out layer-assigned colors and linestyles, objects are drawn in the document object's current color and linestyle.

If you're drawing it manually, you change the current color by selecting a color from the color toolbox.
In a program, you just change the Document's CurrentColor property (optionally saving the original color for re-use later), as was demonstrated by prl.

If you're drawing it manually, you change the current linestyle using the Line Style Toolbox.
In a program, you set the LineType, LineWidth, LineScale, and FilledLine properties in the Document's LineStyle property (which is itself an object with properties and methods).
Dim DcLStyle As DesignCAD.LineStyle
Set DcLStyle = DcDoc.LineStyle
DcLStyle.LineType = dcLineDashed
DcLStyle.LineScale = 2.5
DcLStyle.LineWidth = 0.125
DcLStyle.FilledLine = True


To change the color of an already-drawn entity:
First you have to get that entity somehow -- for example, the first item of a selection set.
Then change the entity's color directly -- something like the code below


'assumes you've already created a DesignCAD.Selection object named DcSel, and at least one items is selected
Dim DcEnt as DesignCAD.Entity
DcEnt = DcSel.Item(1)
Dim entcolor as Long
entcolor = RGB(255, 0, 0) 'make  the entity red
25 years with DesignCAD

casf2012

Thanks to all

But what i want is when i open a saving draw  get a color from a entity, because i need to fill a listview with the color of a entity

for example.

the draw as one polyline i want know the color of that polyline

Sorry for disturbe  :-X

best regards,
Carlos Ferreira


prl

#8
Quote from: casf2012 on November 27, 2014, 01:15:10 AM
get a color from a entity, because i need to fill a listview with the color of a entity

To get a color from an existing entity, see reply #4.  You need to decode the long, assuming you want the red, green, blue components.