5 Replies Latest reply on May 2, 2014 9:08 AM by Jim Sculley

    Parse a drawing note by it's bullet numbering.

    Chris Christy

      I am attempting to parse our Notes on sheet 1 of our drawings for use in a macro. I would like to be able to split the note based upon it's bullet numbering, as some notes are multiline. I would then take this and insert it into a list box. Does anyone know how I can accomplish this? I'm curretly parsing it using split and looking for a vbcrlf but that isnt giving me consistent results due to some of the ways people format text. Any help is appreciated.

       

      Chris C

        • Re: Parse a drawing note by it's bullet numbering.
          Jim Sculley

          If these are notes where everything is an actual bullet number then something like this should work (C# shown, VB is similar):

           

          INote note = selMgr.GetSelectedObject6(1,-1) as Note;

          string propText = note.PropertyLinkedText;

          string[] s = Regex.Split(propText, "<PARA.*>");

           

          Note, Regex.Split does not have an option to ignore empty strings like String.Split has.  So, you will probably have to process the array of strings after the fact to remove empty entries. I tried the above code with a note that looked like this:

           

          1. ONE

          2. TWO IS A LONG NOTE

              THAT WRAPS

          3. THREE

           

          and the array of strings returned was:

           

          ""   <-------- Empty string

          "ONE\r\n"

          "TWO IS A LONG NOTE THAT WRAPS\r\n"

          "THREE"

           

           

          Jim S.

            • Re: Parse a drawing note by it's bullet numbering.
              Chris Christy

              Thanks Jim,

               

              I am sure this would have worked as it seems very much like what I was looking for. Unfortunately it looks like the split method isnt available in VBA regex. I forgot to mention that in my previous post. This will be very useful information though once I progress to VB.Net programming.

               

              On the plus side I did find a way to accomplish what I wanted so I no longer need to find how to split it. It leads to other questions though.

               

              Is it possible to do the following:

               

              1) keep the numbered list format when getting text from a note? I am taking a note, and putting it into a textbox on a userform. I would like to keep the numbers from the numbered list the same if possible, as well as having numbering continue on userform.

               

              2) If can't accomplish 1 excactly, I would like to know if there is a way to make a numbered list as I am setting the note back into Solidworks.

               

              3) Also, if I can accomplish either of the above, how to go about setting Flag Notes on the numbered list?

               

              I am aware I can simply make numbered text and then I assume use <FlagNotes-Flag-1> to set a flag. I would prefer not to do this though if possible.

                • Re: Parse a drawing note by it's bullet numbering.
                  Jim Sculley

                  Chris Christy wrote:

                   

                  Thanks Jim,

                   

                  I am sure this would have worked as it seems very much like what I was looking for. Unfortunately it looks like the split method isnt available in VBA regex. I forgot to mention that in my previous post. This will be very useful information though once I progress to VB.Net programming.

                   

                  On the plus side I did find a way to accomplish what I wanted so I no longer need to find how to split it. It leads to other questions though.

                   

                  Is it possible to do the following:

                   

                  1) keep the numbered list format when getting text from a note? I am taking a note, and putting it into a textbox on a userform. I would like to keep the numbers from the numbered list the same if possible, as well as having numbering continue on userform.

                   

                  This would be difficult.  A plain text box doesn't support bullets and lists, so you would have to do it manually and it is probably more trouble than it is worth.

                   

                  2) If can't accomplish 1 excactly, I would like to know if there is a way to make a numbered list as I am setting the note back into Solidworks.

                   

                   

                  Yes.  You can do this.  SolidWorks uses a custom markup language (sometimes referred to as SWML) in its notes.  The note from my previous example is stored in SW like this:

                  "<PARA  indent=10 findent=-10 number=on ntype=1 nformat=$$. nstartNum=0>ONE\r\n<PARA  indent=10 findent=-10 number=on ntype=1 nformat=$$. nstartNum=0>TWO IS A LONG NOTE THAT WRAPS\r\nTHREE"

                   

                  The PropertyLinkedText property for INote holds the note text in this format.  You can take the information from your form and apply the appropriate markup and set the PropertyLinkedText to the marked up text.

                  3) Also, if I can accomplish either of the above, how to go about setting Flag Notes on the numbered list?

                   

                   

                  I am aware I can simply make numbered text and then I assume use <FlagNotes-Flag-1> to set a flag. I would prefer not to do this though if possible.

                   

                  I don't think this is possible.  For our drawings, we do something this:

                  note.png

                   

                  Jim S.

              • Re: Parse a drawing note by it's bullet numbering.
                Chris Christy

                Thank you again Jim. This is allowing me to do mostly what I wanted to. Is there a way to show a Flag-Triangle in my text box? I'd like to make a checkbox or such to allow people to make that note number a flag, but I havent found any char code to do so. And my textbox wont parse the SWML obviously to show the built in formatting.

                 

                On a similar subject, is there any way to get the indention to work right with wordwrap on a notes that has a flag? As you can see below it doesnt line up after you set a flag. I know I can work around it by breaking the line at the wordwrap and adding spaces but that isnt ideal.

                 

                NOTES.PNG

                 

                btw, setting bordertype=9 will give the flag note. Here is the above formatting.

                 

                NOTES:

                1.     <PARA  indent=7 findent=-6 number=on ntype=1 nformat=$$. nstartNum=1>HERE IS A NOTE
                <PARA  indent=0 findent=0 number=off>
                2.     <PARA  indent=7 findent=-6 number=on ntype=1 nformat=$$. nstartNum=1>HERE IS ANOTHER NOTE
                <PARA  indent=0 findent=0 number=off>
                3.     <PARA  indent=7 findent=-6 number=on ntype=1 nformat=$$. nstartNum=1 bordertype=9>THIS IS A LONG NOTE THAT WRAPS AROUND AND DOESNT LINE UP PROPERLY WITH A FLAG NOTE.
                <PARA  indent=0 findent=0 number=off bordertype=0>
                4.     <PARA  indent=7 findent=-6 number=on ntype=1 nformat=$$. nstartNum=1>LOOK MORE NOTES
                <PARA  indent=0 findent=0 number=off>
                5.     <PARA  indent=7 findent=-6 number=on ntype=1 nformat=$$. nstartNum=1 bordertype=9>OH LOOK ONE LAST NOTE

                 

                Once again, thank you Jim for the helpful answers.