×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Grip Program to Clean-up Text from AutoCAD in Unigraphics NX5
2

Grip Program to Clean-up Text from AutoCAD in Unigraphics NX5

Grip Program to Clean-up Text from AutoCAD in Unigraphics NX5

2
(OP)
This is a follow-up on a subject that I got to work concerning using a grip program to clean-up text from AutoCAD in UG NX5.  ((( Thanks to Amy from GTAC )))
Just goes to show you that you should never give up on something.

        ENTITY/ obj, tn
        STRING/ new_font(30)
        STRING/ obj_text(10,132)  $$ 10 is max lines per note
        DATA/ max_lines, 10
        DATA/ new_font, 'helios_bold_con'

    $$  Create a temporary note to save the current global preferences
        DRAW/OFF
        tn = NOTE/0,0,'TEMP'
        DRAW/ON

        ASGNFT/new_font, 0        $$  Make sure that font is in the table
        n = &FNTNUM(new_font)     $$  Get the number where it is in the table

        MASK/ 25, 27
        INEXTE/ ALL
L100:   obj = NEXTE/ IFEND, L300:

        $$  Change the character font
            DIMPAR/ obj
            &CFONT = n
            GENDIM/ obj

        $$  Edit the text
            DO/ L200:, ii, 1, 7

            $$  Blank out all previously found text
                DO/ L105:, jj, 1, max_lines
                    obj_text(jj) = &NULSTR
L105:           $$ end do jj

            $$  Read next text and show what it was before edits
                obj_text = &DMTEXT(obj, ii, IFERR, L200:)
                PRINT/'WAS', obj_text

            $$  Perform edits as desired
                DO/ L150:, jj, 1, max_lines
                    IF/ obj_text(jj) == &NULSTR, JUMP/L150:
                    last = jj

                $$  Take out every <F1> and <F> and <F2> and <F3>
L110:               y = LENF(obj_text(jj))
                    obj_text(jj) = REPSTR(obj_text(jj), '<F1>', '', 1)
                    obj_text(jj) = REPSTR(obj_text(jj), '<F>', '', 1)
                    obj_text(jj) = REPSTR(obj_text(jj), '<F2>', '', 1)
                    obj_text(jj) = REPSTR(obj_text(jj), '<F3>', '', 1)
                    IF/ LENF(obj_text(jj)) < y, JUMP/L110:


                $$  Strip off all leading and trailing blanks
L120:               y = LENF(obj_text(jj))
                    IFTHEN/ SUBSTR(obj_text(jj), 1, 1) == ' '
                        obj_text(jj) = SUBSTR(obj_text(jj), 2, y - 1)
                        JUMP/ L120:
                    ELSEIF/ SUBSTR(obj_text(jj), y, 1) == ' '
                        obj_text(jj) = SUBSTR(obj_text(jj), 1, y - 1)
                        JUMP/ L120:
                    ENDIF

                $$  Take off leading/trailing 2122 which is not part of a no.
                    IFTHEN/ (y > 4)
                        x = FNDSTR(obj_text(jj), '2122', 1)
                        IFTHEN/ (x == 1)
                            t = ASCII(obj_text(jj), 5)
                            IF/ (t < 48) OR (t > 57), $
                                obj_text(jj) = SUBSTR(obj_text(jj), 5, 132)
                        ELSEIF/ (x == (y - 3))
                            t = ASCII(obj_text(jj), (y - 4))
                            IF/ (t < 48) OR (t > 57), $
                                obj_text(jj) = SUBSTR(obj_text(jj), 1, (y - 4))
                        ENDIF
                        IF/ LENF(obj_text(jj)) < y, JUMP/L120:
                    ENDIF

L150:           $$ end DO jj

            $$  show replacement text
                EDTEXT/obj, obj_text(1..last), ii
                PRINT/'NOW', obj_text

L200:       $$ end DO ii
        JUMP/ L100:

    $$  Set the global preference back to original settings
L300:   DIMPAR/ tn
        DELETE/ tn

        HALT

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources