VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Layer color promt?

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
265 Views, 8 Replies

Layer color promt?

How can I call the layer color promt and capture the users selection trough
vb/vba. If I use windows color object then the knowncolors do not match
acad's.

Andy
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

Andrew Elmore

courtesy of Randall Rath:

calling sub:
Dim lColor As Long
lColor = ChooseColor(lColor, True, lColor)

'Color choice using autocad color selection dialog box
'
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

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
Message 3 of 9
Anonymous
in reply to: Anonymous

Thanks for the reply buy what do I dim "acedSetColorDialog" to. It's looking
for a function but I still can not get the color promt.

Thanks,
Andy
"Jürg Menzi" wrote in message
news:3F048616.F9D4FF50@bluewin.ch...
> Andrew Elmore
>
> courtesy of Randall Rath:
>
> calling sub:
> Dim lColor As Long
> lColor = ChooseColor(lColor, True, lColor)
>
> 'Color choice using autocad color selection dialog box
> '
> 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
>
> Cheers
> --
> Juerg Menzi
> MENZI ENGINEERING GmbH, Switzerland
> http://www.menziengineering.ch
Message 4 of 9
Anonymous
in reply to: Anonymous

Maybe check randall's site - maybe the function is there, or there's some
reference needing set. I couldn't find it in the help either.

"Andrew Elmore" wrote in message
news:11974486DB472FF46FFBF4BA841F0F06@in.WebX.maYIadrTaRb...
>
> Thanks for the reply buy what do I dim "acedSetColorDialog" to. It's
looking
> for a function but I still can not get the color promt.
>
Message 5 of 9
Anonymous
in reply to: Anonymous

Andrew

Ok, ok I shut too fast... you need to declare the AutoCAD API:

Public Declare Function acedSetColorDialog Lib "acad.exe" ( _
ByRef intColor As Long, _
ByRef fAllowMetaColors As Boolean, _
ByRef intNewColor As Long) As Boolean

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
Message 6 of 9
Anonymous
in reply to: Anonymous

Okay i must be an idot because i still can not get this work.

Thanks,

Andy
"Jürg Menzi" wrote in message
news:3F05369B.1FBD816F@bluewin.ch...
> Andrew
>
> Ok, ok I shut too fast... you need to declare the AutoCAD API:
>
> Public Declare Function acedSetColorDialog Lib "acad.exe" ( _
> ByRef intColor As Long, _
> ByRef fAllowMetaColors As Boolean, _
> ByRef intNewColor As Long) As Boolean
>
> Cheers
> --
> Juerg Menzi
> MENZI ENGINEERING GmbH, Switzerland
> http://www.menziengineering.ch
Message 7 of 9
Anonymous
in reply to: Anonymous

Andy

This is my implementation of Randall's color dialog sample:

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

Public Function MeGetAcadColor(DefCol As Long, MtaCol As Boolean, _
LayCol As Long) As Long

MeGetAcadColor = -1

On Error Resume Next

If acedSetColorDialog(DefCol, MtaCol, LayCol) Then
MeGetAcadColor = DefCol
End If

End Function

Works with A2k, A2ki and A2k2...

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
Message 8 of 9
Anonymous
in reply to: Anonymous

I figured out my problem. I needed to change the declare to Private not
public.

Andy

"Jürg Menzi" wrote in message
news:3F091585.77DC76E7@bluewin.ch...
> Andy
>
> This is my implementation of Randall's color dialog sample:
>
> Private Declare Function acedSetColorDialog Lib "acad.exe" (Color As Long,
_
> ByVal bAllowMetaColor As Boolean, ByVal nCurLayerColor As Long) As Boolean
>
> Public Function MeGetAcadColor(DefCol As Long, MtaCol As Boolean, _
> LayCol As Long) As Long
>
> MeGetAcadColor = -1
>
> On Error Resume Next
>
> If acedSetColorDialog(DefCol, MtaCol, LayCol) Then
> MeGetAcadColor = DefCol
> End If
>
> End Function
>
> Works with A2k, A2ki and A2k2...
>
> Cheers
> --
> Juerg Menzi
> MENZI ENGINEERING GmbH, Switzerland
> http://www.menziengineering.ch
Message 9 of 9
Anonymous
in reply to: Anonymous

...:-)

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost