Visual Basic Customization

Reply
*Elmore, Andrew
Post 1 of 9

Layer color promt?

61 Views, 8 Replies
07-03-2003 03:52 AM
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
*Menzi, Jürg
Post 2 of 9

Re: Layer color promt?

07-03-2003 04:37 AM in reply to: *Elmore, Andrew
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
*Elmore, Andrew
Post 3 of 9

Re:

07-03-2003 06:15 AM in reply to: *Elmore, Andrew
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
*Propst, Mark
Post 4 of 9

Re:

07-03-2003 12:41 PM in reply to: *Elmore, Andrew
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.
>
*Menzi, Jürg
Post 5 of 9

Re:

07-03-2003 05:11 PM in reply to: *Elmore, Andrew
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
*Elmore, Andy
Post 6 of 9

Re:

07-05-2003 03:52 AM in reply to: *Elmore, Andrew
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
*Menzi, Jürg
Post 7 of 9

Re:

07-06-2003 03:39 PM in reply to: *Elmore, Andrew
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
*Elmore, Andrew
Post 8 of 9

Re:

07-14-2003 10:11 PM in reply to: *Elmore, Andrew
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
*Menzi, Jürg
Post 9 of 9

Re:

07-15-2003 09:41 PM in reply to: *Elmore, Andrew
...:-)

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

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!