Community
    • Login

    User Defined Language for GCode Help

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 405 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • James RichtersJ
      James Richters
      last edited by

      I’m Trying to develop a User Defined Language for a CNC G Code system. I have it kind of working the only real thing is I can’t get the keywords to work. Is there some way to make a keyword list that overrides everything else?

      Here is what I mean. Here’s a section of my file:
      Screenshot 2023-04-02 173753.png

      I am trying to make Power and Off both key words, but only Off is working, not Power. Power is all multi colored because they can perfix the numbers, but F can also prefix a number but Off still works.

      I’m trying to get words from the keyword list to be orange and if a word is not in the keyword list, it will be red unless they are in a comment or a label and then they will be the comment or label color… that part is working.

      Here only the Off part of Offset is orange, even though Offset is in the same list as Off, and also in I misspell ‘OffSte’ I would like the entire thing to be Red because even though it contains Off, it’s not a valid keyword. I also can’t figure out how to make A-F to be considered numbers after a $ which indicates Hexadecimal which you can also see below
      Screenshot 2023-04-02 175505.png

      Here is my language file:

      <NotepadPlus>
          <UserLang name="ProAuto" ext="Tap" udlVersion="2.1">
              <Settings>
                  <Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
                  <Prefix Keywords1="yes" Keywords2="yes" Keywords3="yes" Keywords4="no" Keywords5="yes" Keywords6="yes" Keywords7="yes" Keywords8="no" />
              </Settings>
              <KeywordLists>
                  <Keywords name="Comments">00; 00: 00~ 01 02 03 04</Keywords>
                  <Keywords name="Numbers, prefix1"></Keywords>
                  <Keywords name="Numbers, prefix2"></Keywords>
                  <Keywords name="Numbers, extras1"></Keywords>
                  <Keywords name="Numbers, extras2"></Keywords>
                  <Keywords name="Numbers, suffix1">.</Keywords>
                  <Keywords name="Numbers, suffix2"></Keywords>
                  <Keywords name="Numbers, range"></Keywords>
                  <Keywords name="Operators1">+ / - * X Y Z I J K F S T M N E , ABS</Keywords>
                  <Keywords name="Operators2">ARC ArcRate ump call return load M e re urn an n ar ophow ool wa pe c</Keywords>
                  <Keywords name="Folders in code1, open"></Keywords>
                  <Keywords name="Folders in code1, middle"></Keywords>
                  <Keywords name="Folders in code1, close"></Keywords>
                  <Keywords name="Folders in code2, open"></Keywords>
                  <Keywords name="Folders in code2, middle"></Keywords>
                  <Keywords name="Folders in code2, close"></Keywords>
                  <Keywords name="Folders in comment, open"></Keywords>
                  <Keywords name="Folders in comment, middle"></Keywords>
                  <Keywords name="Folders in comment, close"></Keywords>
                  <Keywords name="Keywords1">Load Return</Keywords>
                  <Keywords name="Keywords2">Ask</Keywords>
                  <Keywords name="Keywords3">SQR&#x000D;&#x000A;SQRT&#x000D;&#x000A;ARCTAN&#x000D;&#x000A;Tan&#x000D;&#x000A;SIN&#x000D;&#x000A;ARCSIN &#x000D;&#x000A;COS&#x000D;&#x000A;ARCCOS&#x000D;&#x000A;Round</Keywords>
                  <Keywords name="Keywords4">G0&#x000D;&#x000A;G00&#x000D;&#x000A;G1&#x000D;&#x000A;G01&#x000D;&#x000A;G2&#x000D;&#x000A;G92&#x000D;&#x000A;G93&#x000D;&#x000A;G90&#x000D;&#x000A;G80&#x000D;&#x000A;G81&#x000D;&#x000A;G82&#x000D;&#x000A;G83&#x000D;&#x000A;G84&#x000D;&#x000A;G85&#x000D;&#x000A;G86&#x000D;&#x000A;G87&#x000D;&#x000A;G88&#x000D;&#x000A;G89&#x000D;&#x000A;G02&#x000D;&#x000A;G3&#x000D;&#x000A;G03&#x000D;&#x000A;G38&#x000D;&#x000A;G38.3&#x000D;&#x000A;G38.2&#x000D;&#x000A;G4&#x000D;&#x000A;G04&#x000D;&#x000A;G90&#x000D;&#x000A;G80&#x000D;&#x000A;G81&#x000D;&#x000A;G82&#x000D;&#x000A;G83&#x000D;&#x000A;G84&#x000D;&#x000A;G85&#x000D;&#x000A;G86&#x000D;&#x000A;G87&#x000D;&#x000A;G88&#x000D;&#x000A;G89&#x000D;&#x000A;</Keywords>
                  <Keywords name="Keywords5">RATE Offset Q START STOP Array Number Up Down Drawend redraw Diameter draw color circle line Dwell aterial hickness Clearance Rapid Cutting Path Ret Ull able Disable umber pe Vector le Relative Absolute Position ap RPM ump gimov gifee gireplac Program oolup ooldown</Keywords>
                  <Keywords name="Keywords6">MZ&#x000D;&#x000A;MW&#x000D;&#x000A;MV&#x000D;&#x000A;MU&#x000D;&#x000A;MT&#x000D;&#x000A;Power On Off&#x000D;&#x000A;MD&#x000D;&#x000A;Head</Keywords>
                  <Keywords name="Keywords7">=</Keywords>
                  <Keywords name="Keywords8"></Keywords>
                  <Keywords name="Delimiters">00@ 00&amp; 01 02@ 02&amp; 03[ 04 05] 06( 07 08) 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
              </KeywordLists>
              <Styles>
                  <WordsStyle name="DEFAULT" fgColor="FF0000" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="COMMENTS" fgColor="0080FF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="LINE COMMENTS" fgColor="C0C0C0" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="NUMBERS" fgColor="00FF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="KEYWORDS1" fgColor="FCB103" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="KEYWORDS2" fgColor="FF6AFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="KEYWORDS3" fgColor="00FF80" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="KEYWORDS4" fgColor="04D0CB" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="KEYWORDS5" fgColor="FFFF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="KEYWORDS6" fgColor="80FFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="KEYWORDS7" fgColor="3C9DFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="KEYWORDS8" fgColor="8000FF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="OPERATORS" fgColor="FFFF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="DELIMITERS1" fgColor="9797FF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="DELIMITERS2" fgColor="A230FE" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="DELIMITERS3" fgColor="FF8000" bgColor="000000" fontName="" fontStyle="0" nesting="117702655" />
                  <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="DELIMITERS5" fgColor="FFFF80" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                  <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
              </Styles>
          </UserLang>
      </NotepadPlus>
      

      Here’s a partial sample file:

      ;-----------------------------------------
      ; Production Automation 
      ; (c)2023 All Rights Reserved 
      
                ~Machine~ = `ProAuto All`
                ~Program~ = `11 Division C1 B`
        ~Quantity Needed~ =  6
             ~Created by~ = `James M Richters`
           ~Date Created~ = `Sat Apr  1 19:50:08 2023` 
      
      ;------------- Custom Start --------------
             &Count Start& = 0
       Load[M:\CNC_Data\Econ Odome\CNC Divisions\Vertical\~\Start.Tap]
      ;-----------------------------------------
      
        Vector File = M:\CNC_Data\Econ Odome\CNC Divisions\Vertical\2x6\11 Division C1 B.ccd
      
      ;---------- Information Totals -----------
      ;   All XY Contours: 1456.882 Inches
      ;   All Z Downfeeds: 29.006 Inches
      ;   All Rapid Moves: 585.51 Inches
      ;   Estimated Run Time: 13 Minutes 55 Seconds
      ;--------------- Material ----------------
        Material Size       = 5.39398 x 34.27707
        Material Thickness  = 1.5
        Material Offset     = 0 , 0
        Material Draw Color = ($BFE0) : Neon Yellow
        Cuts Outside Material
        Set Clearance = 0 
        Set Rapid     = 0 
        Set Cutting   = 0 
      
      [Job #1 <T17><Rough Square Edge R>]
      ;T17 - Router 0.500 - 1/2 x 1-3/4 Roughing Resharp
      ;------------ Job Information ------------
      ;   Job XY Contours: 7.1 Inches
      ;   Job Z Downfeeds: 4.1 Inches
      ;   Job Rapid Moves: 13.795 Inches
      ;   Estimated Job Time: 3 Seconds
      ;-----------------------------------------
      ;----------- Custom Job Start ------------
      Load [M:\CNC_Data\Econ Odome\CNC Divisions\Vertical\~\Rough Square Edge R Start.Tap]
      ;-----------------------------------------
      
      T17 
      S10000
        Tool Diameter = 0.5 
      Tool Path Color = Sky Blue
      ; Value At Home = 10.411
             XY  Rate = 150
              Z  Rate = 400
      ;        A Axis = 0
      G0 X6.3 Y-0.4 C0
      G0 Z3.25 
      G1 Z-0.85 
      G1 X-0.8 Y-0.4 
      Head Up 
      ;------------ Custom Job End -------------
      Load [M:\CNC_Data\Econ Odome\CNC Divisions\Vertical\~\Rough Square Edge R End.Tap]
      ;-----------------------------------------
      Return
      
      

      Any help getting this to work is greatly appreciated.

      Mark OlsonM Lycan ThropeL 2 Replies Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson @James Richters
        last edited by Mark Olson

        @James-Richters
        I’m not going to go into too much detail trying to figure out implementation, but the EnhanceAnyLexer plugin is your friend here.
        For example, if you want the single letters X, Y, Z, I, J, K, F, S, T, M, N, E (not part of a word) to be colored red, you could do something like:

        0x0000ff = \b[XYZIJKFSTMNE]\b
        

        Or to make 2-4 digit hex numbers preceded by a $ sign blue, you’d use

        0xff0000 = \$[\da-fA-F]{2,4}
        
        1 Reply Last reply Reply Quote 2
        • Lycan ThropeL
          Lycan Thrope @James Richters
          last edited by Lycan Thrope

          @James-Richters ,
          I’m not sure what the problem is that you’re having as I just created a UDL using your code, a sample file from the one you provided, and it seems to be working fine for me without that multicolored Power keyword. There is one with it and I can’t find in your definition for the UDL where those singular or grouped letters would do that goofy multi color stuff. Here’s a screen shot of what I have after I typed in the Power Off keyword set:

          ProAuto.PNG

          @Mark-Olson is right though, that any other coloring changes that would need to have a Regex needed such as your need for a if/or condition should be done using the EnhanceAnyLexer plugin.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors