Basic to VBA Macro Conversion

I have what should work in VBA but if the hilight color and selection color are the same on a  new markup have had both yellow before also.

Anyway if they are both the same the following VBA fails, it only changes the highlight color to the same new color. I was asking for example

Cyan, Magenta ... I even tried scrip files and they also work as long as the two starting colors are not  the same. When opening a new markup

I had a button to change the two settings and only works if the two colors are different at the onset ?

CadInputQueue.SendKeyin "set hilite Yellow"
CadInputQueue.SendKeyin "mdl keyin calculat calc tcb->selectionHiliteColor=5"
CadInputQueue.SendKeyin "m,ms Yellow & Magenta"

the text on the screen says Yellow Magenta, but it will not change the selection set color

Is the results of the above, If I manually change the Gray and Gray to  say gray and blue

 Run the same macro above 

 it works, I cannot control what comes to me, but I do not like gray, gray or the yellow, yellow.

any help ?   Even the following script file works if the starting two colors are not the same

set hilite Green
mdl keyin calculat calc tcb->selectionHiliteColor=5
mdl keyin calculat calc tcb->selectionHiliteOverride=5
m,msGreen & Magenta

hoping I do not get taken to the wood shed on this question. 

Parents
  • Hi Richard,

    hoping I do not get taken to the wood shed on this question. 

    sorry, but I do not understand anything from what you are asking about :-(

    The subject is "BASIC to VBA macro conversion", but there is no single word in the text about any conversion issue. Contrary to it, your text is lenghty description about how some code (unfortunately not inserted as code, which makes text unreadable) works and maybe not.

    What your real issue / question is, formulated in max. 2 sentences and not novel?

    Is it "How to change color settings (3 different colors) from MicroStation VBA?".

    Regards,

      Jan

  • I was going to include the Macro past days of 2004 microstation

    could not find that one but found this VBA one, which fails to work anytime the

    .dgn sent to me has the Highlight color both set to any color. I put up the pictures to attempt to show what I was asking. I have found the VBA only fails to work if the two setting "Element Highlight Color" and the Selection Set color are both on the same color settings. If they are different in any way IE "gray", "blue " Then the attached Macro will change the colors.

    But if the colors are the same neither example VBA Macro or Script will not change the settings to different colors they both follow the Element Highlight Color IE  green and Magenta #5 will both be green. or if you put  cyan and Magenta #5 they will both become cyan. If I manually go to Settings>Design File> color and change either one the VBA macro will again work?

    Again only happens when both colors are the same. I tried it over and over with gray+gray or Magenta+Magenta Blue+Blue Macro fails .

    If I change the top color Element to any other number/color Macro works

    if I change the bottom color Selection Set Macro works fine?

    was hoping for a simple fix. 

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

  • Hello Richard,

    as far as I understand you, you "found" a VBA, that does not work as you expected? 

    Would it not easier to ask the original developer for advice?

    Or share a snippet of the code with us, so maybe someone here could give you a clue?

    Mit freundlichen Grüßen / Best regards
    Volker Hüfner

    |  AB_DATE Engineering  Software   |  ab-date.de  |

  • Dear  Volker, Suru will, I posted the lines above

    will copy and paste them It was:

    set hilite Green
    mdl keyin calculat calc tcb->selectionHiliteColor=5
    mdl keyin calculat calc tcb->selectionHiliteOverride=5

    look at the MDL files as see if 1 was missing

    what I will call a standard .dgn file if the 2 colors are a match

    in a .dgn the automatic way above will not work on  a .dgn

    that seems to  be ok If change either color Manually  the

    to macro's work and the script files also. I even tried via

    Macro. change only Element Highlight highlight color.  

    then use my Macro's to chage elements.

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

  • Hello Richard,


    please use the ‘Insert code’ function here in this forum. It is so much harder to read without. And use paste & copy from your editor to the ‘Insert code’-window. I guess you missed a ‘;’ between ‘…calculat; calc…” Phil Chouinard: mdl keyin calculat...

    Back to the main problem. Manipulating the ‘tcb’ is “soo 20th century.” To quote Jon Summers and dangers, too.

    Best solution is to get rid of this stuff. Just use the ‘record’ function in VBA to get a small, easy to manipulate solution. As Jan Šlegr says: “has been discussed many times already”

    Mit freundlichen Grüßen / Best regards
    Volker Hüfner

    |  AB_DATE Engineering  Software   |  ab-date.de  |

  •  I made this to attempt to solve my problem, symptons remained. Below this is 1 of
     the 1's used for a long time. I have 1 thru 10 various color combinations. Depending
     on what I have to work on. May not even make since, did not put all of them
     because the are redundent other than colors and # value to set colors.
     
    B] - Color Settings HiLi - Removed the VBA and used Key-in Commands test ok 051519
        '    SelColChg8
    
        CadInputQueue.SendKeyin "set hilite Yellow"
        CadInputQueue.SendKeyin "mdl keyin calculat calc tcb->selectionHiliteColor=5"
        
      Below is the one I was/am using. I discovered it only fails if both colors in the 
      .dgn I am opening has both colors set to same color. See Above pictures. I even worked
      with another MicroStation User and show how this macro fails but if you manually change
      Settings>Design File>color to any combination other than both being the same
      then all My SelColChg# macro's work again. I thought someone with VBA experience may
      have had the same problem and figured a work around. I even tried just doing
      a macro with only 1 of the 2 lines below it still change both as if they are lock
      to match no mater how or what you colors you choose. Highlight changes both 
      to the same on every one ? I got the tcb stuff when I did the VBA record ?
      anyway hope this is a bigger help. I got great help from Jan on these or Jon
      NEVER had any problems until I began getting .dgn's to update which came in with
      either Gray & Gray or Yellow & Yellow. I do not like gray as a higllight, but 
      someone does. Anyway that is what caused the questiona and my searching for 
      a new solution. Thank you ........
      
        Sub SelColChg8()
    '052919 - Made New Project HiliteSet____________________________________________ Tested/Worked via Key-in
    ' Colors 0=Black,1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta  , 6=Yellow, 7=White, 8=Gray, 9=Black
    
      '   Start a command
        CadInputQueue.SendCommand "set hilite 3;mdl keyin calculat calc tcb->selectionHiliteColor=1"
        ShowStatus "Cyan & Blue"
        
    CommandState.StartDefaultCommand
    End Sub
    
    Ok I typed some notes in the above code to hopefully get someone to understand. What Jan or Jon gave me in the past the above was seamless until I started receiving the

    .dgn files with both SETTINGS>Design File>Color

    started coming with top and bottom colors the same as shown in the pictures

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

Reply
  •  I made this to attempt to solve my problem, symptons remained. Below this is 1 of
     the 1's used for a long time. I have 1 thru 10 various color combinations. Depending
     on what I have to work on. May not even make since, did not put all of them
     because the are redundent other than colors and # value to set colors.
     
    B] - Color Settings HiLi - Removed the VBA and used Key-in Commands test ok 051519
        '    SelColChg8
    
        CadInputQueue.SendKeyin "set hilite Yellow"
        CadInputQueue.SendKeyin "mdl keyin calculat calc tcb->selectionHiliteColor=5"
        
      Below is the one I was/am using. I discovered it only fails if both colors in the 
      .dgn I am opening has both colors set to same color. See Above pictures. I even worked
      with another MicroStation User and show how this macro fails but if you manually change
      Settings>Design File>color to any combination other than both being the same
      then all My SelColChg# macro's work again. I thought someone with VBA experience may
      have had the same problem and figured a work around. I even tried just doing
      a macro with only 1 of the 2 lines below it still change both as if they are lock
      to match no mater how or what you colors you choose. Highlight changes both 
      to the same on every one ? I got the tcb stuff when I did the VBA record ?
      anyway hope this is a bigger help. I got great help from Jan on these or Jon
      NEVER had any problems until I began getting .dgn's to update which came in with
      either Gray & Gray or Yellow & Yellow. I do not like gray as a higllight, but 
      someone does. Anyway that is what caused the questiona and my searching for 
      a new solution. Thank you ........
      
        Sub SelColChg8()
    '052919 - Made New Project HiliteSet____________________________________________ Tested/Worked via Key-in
    ' Colors 0=Black,1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta  , 6=Yellow, 7=White, 8=Gray, 9=Black
    
      '   Start a command
        CadInputQueue.SendCommand "set hilite 3;mdl keyin calculat calc tcb->selectionHiliteColor=1"
        ShowStatus "Cyan & Blue"
        
    CommandState.StartDefaultCommand
    End Sub
    
    Ok I typed some notes in the above code to hopefully get someone to understand. What Jan or Jon gave me in the past the above was seamless until I started receiving the

    .dgn files with both SETTINGS>Design File>Color

    started coming with top and bottom colors the same as shown in the pictures

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

Children
No Data