Select color by DCL

Select color by DCL

Anonymous
Not applicable
389 Views
5 Replies
Message 1 of 6

Select color by DCL

Anonymous
Not applicable
Hi!

I need can choose one color by DCL.
Is possible call from VB to standard Autocad color DCL ?

Thanks
0 Likes
390 Views
5 Replies
Replies (5)
Message 2 of 6

Ed__Jobe
Mentor
Mentor
Odd...We havn't had that request for a long time. Now you're about the third person to ask that this week. Look for a thread a couple of days ago called "Color selection".

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 6

Anonymous
Not applicable
Than you and sorry by apologizes,

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Odd...We
havn't had that request for a long time. Now you're about the third person to
ask that this week. Look for a thread a couple of days ago called "Color
selection".
0 Likes
Message 4 of 6

Anonymous
Not applicable

I was probing, and it works in VBA, but not in
VB. I need run it from VB, a
ny idea?

 

thanks


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Than you and sorry by apologizes,

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Odd...We
havn't had that request for a long time. Now you're about the third person
to ask that this week. Look for a thread a couple of days ago called "Color
selection".
0 Likes
Message 5 of 6

Anonymous
Not applicable
if this code does not work, make sure windows can find the acad.exe, I would guess that is the problem

Option Explicit

Private Declare Function acedSetColorDialog Lib _
"acad.exe" (color As Long, ByVal bAllowMetaColor _
As Boolean, ByVal nCurLayerColor As Long) As Boolean

Public Function ChooseColor(ByVal lngInitClr As Long, ByVal blnMetaColor As
Boolean, _
ByVal lngCurClr As Long) As Long

ChooseColor = -1

On Error Resume Next

If acedSetColorDialog(lngInitClr, blnMetaColor, lngCurClr) Then
ChooseColor = lngInitClr
End If

On Error GoTo 0

End Function

Sub test_sub()

Dim lColor As Long
Dim R As Long, G As Long, B As Long

lColor = ChooseColor(lColor, True, lColor)

End Sub



"Manuel Pérez Lantarón"
|>Hi!
|>
|>I need can choose one color by DCL.
|>Is possible call from VB to standard Autocad color DCL ?
|>
|>Thanks
|>

James Maeding
Civil Engineer/Programmer
0 Likes
Message 6 of 6

Ed__Jobe
Mentor
Mentor
Here's one I wrote that uses vlax.cls from www.acadx.com.

Public Function AcadColorDialog() As Integer
'calls the acad color dialog and returns
'the index of the color selected or -1 if cancelled
Dim i As Integer
Dim VL As New VLAX

'call color dialog
VL.EvalLispExpression ("(setq clr (acad_colordlg 1))")
'if dialog was canceled, clr will be nil, set to -1 instead
i = VL.EvalLispExpression("(if (= clr nil)(setq clr -1)(setq clr clr))")
AcadColorDialog = i
Set VL = Nothing
End Function

If you don't want to use that class, you could modify this sub that I used SendCommand to execute the lisp and stores the color number in USERI1 and then retrieve it with GetVariable. With this function, if the user cancels the color dialog, -1 is returned. With the previous function, the color returned is the same as the argument supplied to the function. It remains unchanged.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes