Tried this a few moments ago and it lockup and I lost my message.
The two items are what I want to change. I have a VBA macro that will preform this, but It seems so involved. I know someone with the knowledge can do it easy. I will post the macro.
' 1112133 - Modified, removed the Dim commands at top, removed CommandState.StartDefaultCommand' 11/02/11 - Made New Replacement for the Older version. Deleted older' macro and re-named new one to match older one. removed Macro 3 Handler 11 'Dim startPoint As Point3d 'Dim point As Point3d, point2 As Point3d 'Dim lngTemp As Long
Dim modalHandler As New Macro3ModalHandler11 SEE BELOW THE Macro3 Handler11 AddModalDialogEventsHandler modalHandler
' The following statement opens modal dialog "Design File Settings"
' Start a command CadInputQueue.SendCommand "MDL SILENTLOAD DGNSET"
CadInputQueue.SendCommand "MDL SILENTUNLOAD DGNSET"
RemoveModalDialogEventsHandler modalHandler
Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)
If DialogBoxName = "Design File Settings" Then
' Set a variable associated with a dialog box SetCExpressionValue "dgnSet.hiliteColor", 8, "DGNSET"
SetCExpressionValue "dgnSet.selSetColor", 5, "DGNSET"
' Remove the following line to let the user close the dialog box. DialogResult = msdDialogBoxResultOK
End If ' Design File Settings
End Sub
This seems an awful lot just to change two colors, I searched and read for a while, but did not find the answer?
Another option would be to use "key-ins":
set hilite white mdl keyin calculat calc tcb->selectionHiliteOverride=1 mdl keyin calculat calc tcb->selectionHiliteColor=5
The number at the end of the last statement is the number (from the top) of the color in the picklist. The second statement is needed in instances where the Element Hilite color and Selection Set color are different. You can concatenate those by putting them on one statement separated by ; semi-colons.
Answer Verified By: RJB
RJB said:This seems an awful lot just to change two colors, I searched and read for a while, but did not find the answer?
It's the way how VBA macro recorder works. From human perspective it's very stupid assistant, which record everything in a normalized way, so often the result is more complicated than an approach used by experienced user or a code written by developer. Because Preferences dialog is modal, the code is even mode complex because of used handlers.
In fact what Phil recommend (to use calculator to set tcb values) is more straightforward and more "MicroStation like" solution, but with the same result, as SetCExpressionValue method (that is MicroStation VBA API).
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thanks again, Phil. This is just what I was looking for:
The only lines I need are the {mdl keyin calculate calc tcb->selectionHiliteOverride=1 and the one below it to change the two colors? I noticed the Macro Handler referenced
SetCExpressionValue "dgnSet.hiliteColor", 3, "DGNSET"
So I kept looking for a Key-in command with Set Color or Change color or Color change. Thanks to all who try to help this old guy keep a job.
RJB Phillips III - Praise the Lord for His Mercy and Grace
Phil, I could not get the Highlight to change? I tried the command three ways
mdl keyin calculat calc tcb->selectionHiliteOverride=1;mdl keyin calculat calc tcb->selectionHiliteColor=3 selection change only
mdl keyin calculat calc tcb->selectionHiliteOverride=1;mdl keyin calculat calc tcb->selectionHiliteColor=5 selection changed only
mdl keyin calculat calc tcb->selectionHiliteOverride=7;mdl keyin calculat calc tcb->selectionHiliteColor=5 Nothing seemed to work
I never mess with the center selection only the top one and bottom one. It seemed the command only worked on the Selection Set Color and not on the Element highlight color?
There are three commands:
set hilite white
1. That sets the Element Hilite color.
mdl keyin calculat calc tcb->selectionHiliteOverride=1
2. That is a logical TRUE or FALSE and can only be 1 (enabled) or 0 (disabled). Enabling that ensures that the Element Hilite and Selection Set Hilite can be different values. Disabling that "locks" the Element Hilite and Selection Set Hilite to be the same. The user interface "hides" the fact that setting the two Hilite colors to different values enables that in the background. BTW, this is a single bit value, with bit 0 of any number it is set to being the only thing it looks at. Since all even positive integers (e.g. 2, 4, 8, 1024, etc.) have bit 0 as 0, that disables it. All odd positive integers (e.g. 1, 3, 5, 255, etc.) have bit 0 as 1, when enables it.
mdl keyin calculat calc tcb->selectionHiliteColor=5
3. That sets the Selection Set Hilite color.
In your concatenated command, you only have the 2nd and 3rd commands. If you include the 1st, you will likely see the behavior you want.
Special Thanks to Phil, who bails me out so many times. Due to the help toward Key-in commands I was able to figure out the following for setting Layers via Key-in,
' Start a command
CadInputQueue.SendCommand "ACTIVE LEVEL ""Level 4"""
' Set a variable associated with a dialog box
CadInputQueue.SendCommand "ACTIVE Color Orange"
CadInputQueue.SendCommand "ACTIVE STYLE 0"
CadInputQueue.SendCommand "ACTIVE WEIGHT 1"
CadInputQueue.SendCommand "m,ms Active Level=4 Color 4, Style 0, Weight 1" 'Send Msg Center Box
but I cannot figure out how to add the Script file location to the search path. I know it is in configuration, but do now know where.
Hi Richard,
I'd like to ask why do you use VBA to send key-ins to MicroStation? If there is not some specific requirement not discussed in this thread, it's bad approach to do it this way ... it's general rule: If CadInputQueue.SendCommand is used in VBA code, it's very often (exceptions exist of course) bad use of VBA and a mistake in the macro design.
Compare this:
RJB said:but I cannot figure out how to add the Script file location to the search path. I know it is in configuration, but do now know where.
Not quite sure what you are asking for, probably because of misuse of terms (and it's really necessary to use the right terms!). Your post is about VBA code and script files are note mentioned at all. So please specify better your question: Are you interested in script files use (key-in @<script_file>) or in VBA load?
RJB said: ' Start a command CadInputQueue.SendCommand "ACTIVE LEVEL ""Level 4"""
' Start a command CadInputQueue.SendCommand "ACTIVE LEVEL ""Level 4"""
The key-in active level doesn't start any command, it set a proper active attribute (level in this case) in the same way as other active <something> key-ins. So the comments in your code are not correct.
Jan, thank you for the reply. I try to cut down on time and typing. Phil gave me a way to change the VBA and I was able to drop all the MacroHandlers from them. But I have tool bar Icons that change level and all the settings and then some to change the hilite and select commands. My job is all about time/productivity. I was blessed to learn about the lock section being available in the Level Manager. That is working real fast for me and I get to check several at one time. you folks are patient and kind. Sometimes the VBA record will not pickup anything, so I resorted to using the Keyin command in the macro to do what I could not figure out. I even tried some of the things in the old BASIC, but same problem It did not pickup some of the mouse clicks and values. I really like the VBA the best, the scripts was just something I was trying to learn so I could evaluate which was the best.
Just giving you and example:
Just trying to give you an example, the LCL are Cell Lib's for various things
I will try and use your example and see if I can make a script and tie that to the button and skip the VBA. But I like the F8 feature, and it finds my errors the script I have to put in a line at a time to test and move on??
The above response was tried, it did not all work?
The above was the Message section Red X ??? the text looked ok, next the actual Key-in command used
I believe I got the key in the way it was outlined? as you see, Orange worked, style also and the weight did fine, but the Level stayed on 1
Any further assistance I might get on how I could correct it? oh, I see a space missing , will try again. Sorry.