×
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

Using Grip To Edit Text In NX Drafting
5

Using Grip To Edit Text In NX Drafting

Using Grip To Edit Text In NX Drafting

(OP)
Due to UG not having True Type Font in Drafting, I currently bring AutoCAD artwork files into UG.  The text will appear like this in the UG Annotation Editor: <F1>1000-1234<F>. We assign a new font (helios_bold_con) to the text. In order for the system to recognize the new font, you must edit the text and remove the <F1> & <F>.
Can anyone help me write a grip program to strip this from each piece of text on a drawing? There may be 20-100 occurrences on a drawing that needs editing.

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

Editting text strings with GRIP has always been hard as that function is not supported by GRIP.

Try to mask/25 for text entities, pick it with an ident statement, delete the existing string, edit the string, then create a new note with the revised string in the old location.

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
Sr IS Technologist
L-3 Communications

RE: Using Grip To Edit Text In NX Drafting

(OP)
You might have to be a little more specific. I'm very limited in my Grip programming knowledge.
Could we come up with a program that would let me pick a text string then delete the first 4 characters and the last 4 characters of that text string then let me pick another without terminating, and maybe Cancel or Esc if I want to terminate the program.

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

lsl49,

Yes...it's possible, just depends on what you want.  You could write a routine that will cycle through all dwg sheets and notes removing the offending chars without user input, or you could have the user pick each note individually.  Each has advantages and disadvantages... If your likely to have text strings with these chars that you will want to keep, then I'd go with having the user select them.  Otherwise, I'd have it go globally and take the chance of a user error (missing one) out of the equation.  You could even set it up to cycle through the notes automatically and give the user a choice on whether or not to edit it or go to the next one...

Regards,
SS
CAD should pay for itself, shouldn't it?

RE: Using Grip To Edit Text In NX Drafting

(OP)
This sounds like what I might want. Can you give any help on getting started?

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

And now for some code:

CODE

ENTITY/L
NUMBER/ORIG(3),LNS,RSP
STRING/NTXT(132),RTXT(132)

L1:
  MASK/25  $$DRAFTING OBJECTS
  IDENT/'INDICATE NOTE',L,RSP
  JUMP/L1:,L1:,,RSP
  $$ SAVE ORIGIN OF NOTE,
  $$ SINCE WE WILL HAVE TO DELETE THE OLD NOTE
  $$ AND PLACE A NEW ONE
  ORIG(1..3)=&ORIGIN(L)

  $$ RETRIEVE TEXT OF OBJECT
  NTXT=&DMTEXT(L)

  $$ REPLACE TEXT IN NOTE
  RTXT=REPSTR(NTXT,'<F1>','',1)
  RTXT=REPSTR(RTXT,'<F>','',1)
  $$ CREATE NEW NOTE
  NOTE/ORIG(1),ORIG(2),RTXT
  $$ DELETE OLD NOTE
  DELETE/L

  HALT

Bear in mind that this is only to get you started, it does not do any error checking and could use improvements. For instance, it only runs once (easily fixed with a loop), it only checks for <F1> and <F> (if there is <F2> or <F3>,etc it will miss them), and it does not check for multi line notes.

All of the above shortcomings are fixable and you will probably want to change it so that it runs with no user intervention to minimize missed notes.

RE: Using Grip To Edit Text In NX Drafting

(OP)
YES THIS IS A GOOD START HOWEVER I DO NEED THE LOOP, MULTIPLE LINE CHECK AND WITH NO USER INTERCENTION.

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

(OP)
Thought I better try this again.............

Yes this is a very good start however I do need the LOOP, MULTIPLE LINE CHECK and NO USER INTERVENTION if at all possible.  This text is placed in one the model for a visual check against the associated AutoCAD file.   Since you must be in Drafting to EDIT text, there will be only one drawing per part.

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

(OP)
In addition to the following POST, I need the font set to helios_bol_con.

thanks

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

Instead of grip take a look at the sample applications that ship with NX (C:\Program Files\UGS\NX 3.0\UGOPEN\SampleNXOpenApplications) They have some vb sample applications that will get you started. VB would be easier to understand since it has been around for so long and there are tons of examples on the web. The only disconnect you may have is applying that to the NX/Open object model.

PLM Exchange
http://plmexchange.net
http://groups-beta.google.com/group/NX_CAX/

RE: Using Grip To Edit Text In NX Drafting

(OP)
Sorry but we are on version 2.0.2.2

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

I'd be glad to refine the program for you, however things are busy at the moment. I did find this in the grip library, it may do the trick. I have not tried it myself so I cannot comment on its use or how well it works.

CODE

$$ PROGRAM: REPLACE_TEXT.GRS
$$
$$ KEYWORDS:
$$
$$ ABSTRACT: A search and replace program that globally replaces
$$           existing note text with new keyed-in text.
$$
$$ RELEASE HISTORY:
$$   19-NOV-86 INITIAL RELEASE, DEWAYNE EVANS
$$   15-JUN-87 REVISION 0, DEWAYNE EVANS
$$   01-AUG-87 SUBMITTED TO LIBRARY
$$
$$ Required Subroutines: (None)
$$
$$ AUTHOR: DEWAYNE EVANS
$$ TITLE:
$$ COMPANY: McDonnell Douglas M & E
$$          Santa Clara, CA
$$          408-727-6990
$$
$$ SYSTEM TYPE:
$$
NUMBER/CCF,CCS,CEC,CES,CTA,CTD,CTJ,CWL,DAD(23),DFV,DLV,EL(3),EP,FS
NUMBER/NEP,NSP,QE,RSP,SDLV,SL,SP,SSDLV,TS
ENTITY/CWCS,ENT(1000),N
STRING/ITXT(132),NT(132),NTXT(132),OT(132)
    DATA/SP,1,EP,0,DFV,2
$$
$$
$$  ENTITY VARIABLES:
$$  ENT = ENTITY, N = NOTE
$$
$$  STRING VARIABLES:
$$  OT = OLD TEXT, NT = NEW TEXT
$$  ITXT = INITIALIZE TEXT, NTXT = NOTE TEXT
$$
$$  NUMBER VARIABLES:
$$  QE = QUANTITY OF ENTITIES, SP = START POSITION, EP = END POSITION
$$  LNT = LENGTH OF NEW TEXT, SL = STRING LENGTH, FS = FIND STRING
$$  NEP = NEW END POSITION, DAD = DRAFTING AID DATA
$$  EL = ENTITY LOCATION, DLV = DO-LOOP VARIABLE, DFV = DEFAULT VALUE
$$  SDLV = SUB-DO-LOOP VARIABLE, SSDLV = SECOND SUB-DO-LOOP VARIABLE
$$  NSP = NEW START POSITION, TS = TERMINATION SWITCH
$$
$$
    CWL=&WLAYER  $$ CURRENT WORK LAYER
    CCF=&CFONT   $$ CURRENT CHAR FONT
    CCS=&CSIZE   $$ CURRENT CHAR SIZE
    CWCS=&WCS    $$ CURRENT WCS
    CEC=&ENTCLR  $$ CURRENT ENTITY COLOR
    CTJ=&TXJUST  $$ CURRENT TEXT JUSTIFICATION
    CES=&ENSITE  $$ CURRENT ENTITY SITE
    CTD=&TDENS   $$ CURRENT TEXT DENSITY
    CTA=&TXANGL  $$ CURRENT TEXT ANGLE
$$
$$
IA05:
    CHOOSE/'READ HELP FILE',$
           'YES',           $
           'NO',            $
    DEFLT,DFV,RSP
    JUMP/IA05:,TERM:,,,HELP10:,IA10:,RSP
$$
$$
IA10:
    TS=1         $$ TERMINATION SWITCH ON
    DFV=1
    TEXT/'ENTER OLD TEXT',OT,RSP
    JUMP/IA05:,TERM:,IA10:,,IA20:,RSP
$$
$$
IA20:
    TS=2         $$ TERMINATION SWITCH OFF
    TEXT/'ENTER NEW TEXT',NT,RSP
    JUMP/IA10:,TERM:,IA20:,,IA30:,RSP
$$
$$
IA30:
    PARAM/'SEARCH POSITIONS',$
          'START',INT,SP,    $
          'END',INT,EP,RSP
    JUMP/IA20:,TERM:,,RSP
    IF/SP-1,EM10:,,
    JUMP/IA40:
$$
$$
EM10:
    MESSG/'START VALUE','MUST BE > 0'
    JUMP/IA30:
$$
$$
IA40:
    MASK/25
    &WCS=CSYS/&WVIEW
    IDENT/'SELECT TEXT',ENT,CNT,QE,RSP
    JUMP/IA30:,TERM:,DL10:,RSP
$$
$$
DL10:            $$ SEARCH AND REPLACE TEXT STRINGS
    MESSG/TEMP,'SEARCHING'
    DO/DLL10:,DLV,1,QE
    IF/&SUBTYP(ENT(DLV))-1,,,DLL10:
    ITXT=&DMTEXT(ENT(DLV))
    SL=LENF(ITXT)
    IF/SP-SL,,DLL10:,DLL10:
    FS=FNDSTR(ITXT,OT,SP)
    IF/FS+0,,DLL10:,
    NTXT=REPSTR(ITXT,OT,NT,FS)
    IF/SP-EP,DL30:,ID10:,DL20:
$$
$$
DL20:            $$ SEARCH ENTIRE TEXT STRING
    DO/DLL20:,SDLV,1,132
    NSP=FS+LENF(NT)
    FS=FNDSTR(NTXT,OT,SP)
    IF/FS+0,,ID10:,
    NTXT=REPSTR(NTXT,OT,NT,FS)
  DLL20:
$$
$$
DL30:            $$ SEARCH UP TO END POSITION
    DO/DLL30:,SSDLV,1,132
    NSP=FS+LENF(NT)
    NEP=LENF(NTXT)-LENF(ITXT)+EP
    FS=FNDSTR(NTXT,OT,NSP)
    IF/FS+0,,ID10:,
    IF/NSP-NEP,,ID10:,ID10:
    NTXT=REPSTR(NTXT,OT,NT,FS)
  DLL30:
$$
$$
ID10:            $$ REPLACE TEXT STRINGS
    &WLAYER=&LAYER(ENT(DLV))
    &ENTCLR=&COLOR(ENT(DLV))
    OBTAIN/ENT(DLV),DAD
    &CSIZE=DAD(1)
    &CFONT=DAD(3)
    &TXJUST=DAD(2)
    &ENSITE=DAD(19)
    &TDENS=DAD(4)
    &TXANGL=DAD(5)
    EL=&ORIGIN(ENT(DLV))
    DELETE/ENT(DLV)
    N=NOTE/EL(1),EL(2),NTXT
  DLL10:
    JUMP/IA10:
$$
$$
HELP10:
    PRINT/'THIS PROGRAM REPLACES EXISTING NOTE TEXT WITH NEW'
    PRINT/'KEYED IN TEXT.'
    PRINT/''
    PRINT/'FIRST, KEY IN THE OLD TEXT (THE TEXT TO BE REPLACED).'
    PRINT/''
    PRINT/'SECOND, KEY IN THE NEW TEXT (REPLACEMENT TEXT).'
    PRINT/''
    PRINT/'THIRD, INDICATE THE START POSITION. THE START'
    PRINT/'POSITION TELLS THE PROGRAM AT WHAT CHARACTER WITHIN'
    PRINT/'THE NOTE TO BEGIN LOOKING FOR THE OLD TEXT. (A START'
    PRINT/'POSITION OF 1 WOULD INDICATE THE BEGINING OF A NOTE).'
    PRINT/''
    PRINT/'FOURTH, INDICATE THE END POSITION. THE END POSITION'
    PRINT/'TELLS THE PROGRAM AT WHAT CHARACTER WITHIN THE NOTE'
    PRINT/'TO STOP SEARCHING FOR THE OLD TEXT. AN END POSITION'
    PRINT/'OF 0 TELLS THE PROGRAM TO SEARCH THE ENTIRE NOTE.'
    PRINT/''
    PRINT/'NOTE: THIS PROGRAM EDITS NOTE ENTITIES ONLY. THE NEW TEXT'
    PRINT/'IS CREATED IN THE CURRENT WORK VIEW. ALSO, IT DOES NOT'
    PRINT/'ACCOMODATE NOTES WITH MULTIPLE LINES OF TEXT.'
    JUMP/IA10:
$$
$$
TERM:
    IF/TS-1,,,IA10:
    &WLAYER=CWL
    &WCS=CWCS
    &ENTCLR=CEC
    &CFONT=CCF
    &CSIZE=CCS
    &TXJUST=CTJ
    &ENSITE=CES
    &TDENS=CTD
    &TXANGL=CTA
    HALT

RE: Using Grip To Edit Text In NX Drafting

(OP)
OK, I would greatly appreciate it.  I will also be working on it at this end.

PS: The above program works fine but does not do what I want and requires user intervention which we can not have (user error factor).

Here are the factors to consider:
1-Removing <F1> and <F>
2-Remove any brackets containing <K??> and <K>. (example: <K46> )
3-Text string may be multiple lines of text so consider when writing the code.
(example: <F1><U>ABC
                 DEFG HIJK
                 1234-5678<F><U>

(Note: This text is underlined which I want to keep so only remove <F1> and <F>.)
4-Origin of text should remain the same as original text.
5-Set text font to helios_bold_con.
6-Cycle through whole drawing without user intervention.

This would be an extra if not to much trouble:

7-Remove all occurrences of digits 2122 from text strings when they follow text characters (example: ABC2122).
(This is a diamond character in AutoCAD but comes in as numbers in UG).

This is all I can think of at this time.

thanks,

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

(OP)
Strike through #2-Remove any brackets containing <K??> and <K>. (example: <K46> ).
This actually assign color to the text and this is OK.
One thing I did forget on the list was to keep existing properties like color, character size and origin.
I'm learning as I go here about what is going on from AutoCAD into UG so other things may change.

thanks,

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

(OP)
cowski,
Need the new text to be same size, color and origin as old text and be helios_bold_con.

Larry Leonard
Senior Designer

Smith-Nephew Orthopaedics

RE: Using Grip To Edit Text In NX Drafting

(OP)
Any chance I can get someone to revisit this for me?

Larry

RE: Using Grip To Edit Text In NX Drafting

Well... what have you done so far?  Perhaps posting the areas of code your having trouble with would help.  If, on the otherhand, your expecting Cowski or others to create a routine for you then you'll likely be waiting for a good long time.  Your original post asked for help writing the code, implying that you would do the coding and you just needed a nudge or two in the right direction to overcome a problem or two.  So far, this thread reads like your expecting Cowski to (out of the goodness of his heart when he's got nothing better to do) design, code, debug, and tweak as desired a program.

If you want someone to take the time and effort to write a code for you, then just ask around and I'm sure some arrangeements can be made.  If nobody around here is interested, just hit the web and there's a number of companies out there that will be happy to help you out.

Hope this helps....

Regards,
SS
CAD should pay for itself, shouldn't it?

RE: Using Grip To Edit Text In NX Drafting

(OP)
Below you will see what I have so far. It looses the properties of the original text.  Someone from told me I should try edit text (EDTEXT) which would retain the properties. I do not know how to incorporate this into this existing program.

$*********************************************************
ENTITY/L, ents(1000)

NUMBER/ORIG(3),LNS,RSP, cntr, spot
STRING/NTXT(132),RTXT(132)

data/ cntr, 0

  inexte/ all
  
  MASK/25  $$DRAFTING OBJECTS

L1:
    spot = -1
    L = nexte/ ifend, Z99:
    if/ L == &nulent, jump/ z99:
  
    ORIG(1..3)=&ORIGIN(L)

    $$ RETRIEVE TEXT OF OBJECT

$$ COPY SETTINGS $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

    E_CLR=&ENTCLR
    W_LAY=&WLAYER
    C_SIZ=&CSIZE
    C_FNT=&CFONT
    E_SIT=&ENSITE
    T_JUS=&TXJUST
  
    NTXT=&DMTEXT(L)
  
    spot = FNDSTR(NTXT,'<F1>',1)

    ifthen/ spot >= 1
        cntr = cntr + 1
        ents(cntr) = L

        $$REPLACE TEXT IN NOTE
        RTXT=REPSTR(NTXT,'<F1>','',1)
        RTXT=REPSTR(RTXT,'<F>','',1)
        $$CREATE NEW NOTE
        NOTE/ORIG(1),ORIG(2),RTXT
        $$ DELETE OLD NOTE
        $$ DELETE/L       $$ we can't delete while cycling
    endif
  
    jump/ L1:
  
Z99:

    $$        done cycling, so now delete all the old notes
    ifthen/ cntr > 0
        delete/ ents(1..cntr)
    endif
    
    print/ 'CNTR: ', cntr
    
  HALT

$***************************************************

lsl49


RE: Using Grip To Edit Text In NX Drafting

You need to get the settings from your original string of text, use those values for your current settings, then write your note.


What is happening is the new note is being written at the default settings, not the original settings.

Add a section at the top of your code to capture the default settings.
    E_CLR_0=&ENTCLR
    W_LAY_0=&WLAYER
    C_SIZ_0=&CSIZE
    C_FNT_0=&CFONT
    E_SIT_0=&ENSITE
    T_JUS_0=&TXJUST

Change the section you have where you are saving the settings to save them from the string instead of global settings.
    E_CLR=&ENTCLR(L)
    W_LAY=&WLAYER(L)
    C_SIZ=&CSIZE(L)
    C_FNT=&CFONT(L)
    E_SIT=&ENSITE(L)
    T_JUS=&TXJUST(L)

Now set your system to these values.
    &ENTCLR=e_clr
    &WLAYER=w_lay
    &CSIZE=c_siz
    &CFONT=c_fnt
    &ENSITE=e_sit
    &TXJUST=t_jus

Write your note.

Then reset the values to the system defaults.
    &ENTCLR=e_clr_0
    &WLAYER=w_lay_0
    &CSIZE=c_siz_0
    &CFONT=c_fnt_0
    &ENSITE=e_sit_0
    &TXJUST=t_jus_0

This will reset the system back to the way it was before you executed your program.

ALWAYS cleanup after yourself!

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
Sr IS Technologist
L-3 Communications

RE: Using Grip To Edit Text In NX Drafting

(OP)
Here is what I have.
It will not compile.  I receive error 79 undefined GPA symbol for (L).

$********************************

ENTITY/L, ents(1000)

NUMBER/ORIG(3),LNS,RSP, cntr, spot
STRING/NTXT(132),RTXT(132)

data/ cntr, 0

  inexte/ all

$$ CAPTURE CURRENT SYSTEM SETTINGS $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    E_CLR_0=&ENTCLR
    W_LAY_0=&WLAYER
    C_SIZ_0=&CSIZE
    C_FNT_0=&CFONT
    E_SIT_0=&ENSITE
    T_JUS_0=&TXJUST
  
  MASK/25  $$DRAFTING OBJECTS

L1:
    spot = -1
    L = nexte/ ifend, Z99:
    if/ L == &nulent, jump/ z99:
  
    ORIG(1..3)=&ORIGIN(L)

$$ COPY CURRENT TEXT STRING SETTINGS $$$$$$$$$$$$$$$$$$$

    E_CLR=&ENTCLR(L)
    W_LAY=&WLAYER(L)
    C_SIZ=&CSIZE(L)
    C_FNT=&CFONT(L)
    E_SIT=&ENSITE(L)
    T_JUS=&TXJUST(L)

    $$ RETRIEVE TEXT OF OBJECT
  
    NTXT=&DMTEXT(L)
  
    spot = FNDSTR(NTXT,'<F1>',1)

    ifthen/ spot >= 1
        cntr = cntr + 1
        ents(cntr) = L

        $$              REPLACE TEXT IN NOTE
        RTXT=REPSTR(NTXT,'<F1>','',1)
        RTXT=REPSTR(RTXT,'<F>','',1)
        $$              CREATE NEW NOTE

$$ SET SYSTEM TO THESE VALUES $$$$$$$$$$$$$$$$$$$$$$$$$$$$
    &ENTCLR=e_clr
    &WLAYER=wlay
    &CSIZE=c_size
    &CFONT=c_fnt
    &ENSITE=e_sit
    &TXJUST=t_jus

$$ SET CFONT TO HELIOS_BOLD_CON $$$$$$$$$$$$$$$$$$$$$$$$$$

SET     
    C_FNT=&CFONT(4)

        NOTE/ORIG(1),ORIG(2),RTXT
        $$ DELETE OLD NOTE
        $$ DELETE/L        $$ we can't delete while cycling
    endif
  
    jump/ L1:
  
Z99:

    $$         done cycling, so now delete all the old notes
    ifthen/ cntr > 0
        delete/ ents(1..cntr)
    endif
    
    print/ 'CNTR: ', cntr

$$ RESET SYSTEM TO ORIGINAL SETTINGS $$$$$$$$$$$$$$$$$$$$$
    &ENTCLR=e_clr_0
    &WLAYER=wlay_0
    &CSIZE=c_size_0
    &CFONT=c_fnt_0
    &ENSITE=e_sit_0
    &TXJUST=t_jus_0
    
  HALT

$********************************************************

thanks,
lsl49

RE: Using Grip To Edit Text In NX Drafting

(OP)
Can someone tell what is wrong?

lsl49

RE: Using Grip To Edit Text In NX Drafting

You are confusing global parameters with entity specific parameters. For example, the Global Parameter Access (GPA) &ENTCLR sets the current modeling color only. So if the current color is green and you set it to blue, all entities you create after that will be blue. To use &ENTCLR(L) is an error because it is the wrong command to query or set an individual entity's color (use the Entity Data Access Symbol (EDA) &COLOR(L) to do that). Welcome to the wonderful world of grip programming. You probably now see why its use is no longer greatly encouraged.

Sort out the GPA's and the EDA's and you are well on your way to a working program (it also doesn't like the SET command sitting by itself on line 61). To change the font, look up the ASGNFT command.

RE: Using Grip To Edit Text In NX Drafting

It can be useful to have the capture/restore system settings (i.e. GPA's) as sub-routines that you call at the start and end of your program.

I use an _GPA_SAVE.GRS ...

Proc/ Gpavlu
Number/ Gpavlu(43)

Gpavlu(1)  = &Apsite
Gpavlu(2)  = &Aunit
Gpavlu(3)  = &Cfont
Gpavlu(4)  = &Cnmode
Gpavlu(5)  = &Csize

return

and an _GPA_REST.GRS ...

Proc/ Gpavlu
Number/ Gpavlu(43)

&Apsite = Gpavlu(1)
&Aunit  = Gpavlu(2)
&Cfont  = Gpavlu(3)
&Cnmode = Gpavlu(4)
&Csize  = Gpavlu(5)

return

Paul Phillips
Specialty Engineered Automation
http://www.sea4ug.com

RE: Using Grip To Edit Text In NX Drafting

(OP)
Using the _GPA_SAVE & _GPA_REST & using ASGNFT to assign the font as suggested in a above post:

It reported an error "subscript a non-array variable" on the line 19 (calling out the helios_bold_con font) and program failed compilation.

I received 2 linking errors when I tried to link.
In _GPA_SAVE called from test_program. Wrong number of argumnets _GPA_SAVE
In _GPA_REST called from test_program. Wrong number of
arguments _GPA_REST
----------------------------------------------
Here are the sub-routines:

$****************_GPA_SAVE.GRS****************
Proc/ Gpavlu
Number/ Gpavlu(43)

Gpavlu(1)  = &Apsite
Gpavlu(2)  = &Aunit
Gpavlu(3)  = &Cfont
Gpavlu(4)  = &Cnmode
Gpavlu(5)  = &Csize

return

-------------------------------------------------

$***********_GPA_REST.GRS****************
Proc/ Gpavlu
Number/ Gpavlu(43)

&Apsite = Gpavlu(1)
&Aunit  = Gpavlu(2)
&Cfont  = Gpavlu(3)
&Cnmode = Gpavlu(4)
&Csize  = Gpavlu(5)

return

------------------------------------------------------

Here is the current program:
$********************************

ENTITY/L, ents(1000)

NUMBER/ORIG(3),LNS,RSP, cntr, spot
STRING/NTXT(132),RTXT(132)

data/ cntr, 0

  inexte/ all
  
  MASK/25  $$DRAFTING OBJECTS

$$  Call Subroutine
      CALL/'_GPA_SAVE'

$$ SET CFONT TO HELIOS_BOLD_CON $$$$$$$$$$$$$$$$$$$$$$$$$$
    ASGNFT/Gpavlu(3),4,IFERR,L1:

L1:
    spot = -1
    L = nexte/ ifend, Z99:
    if/ L == &nulent, jump/ z99:
  
    ORIG(1..3)=&ORIGIN(L)

    $$ RETRIEVE TEXT OF OBJECT
  
    NTXT=&DMTEXT(L)
  
    spot = FNDSTR(NTXT,'<F1>',1)

    ifthen/ spot >= 1
        cntr = cntr + 1
        ents(cntr) = L

        $$              REPLACE TEXT IN NOTE
        RTXT=REPSTR(NTXT,'<F1>','',1)
        RTXT=REPSTR(RTXT,'<F>','',1)
        $$              CREATE NEW NOTE

        NOTE/ORIG(1),ORIG(2),RTXT
        $$ DELETE OLD NOTE
        $$ DELETE/L        $$ we can't delete while cycling
    endif
  
    jump/ L1:
  
Z99:

    $$         done cycling, so now delete all the old notes
    ifthen/ cntr > 0
        delete/ ents(1..cntr)
    endif
    
$$  Call Subroutine
      CALL/'_GPA_REST'

    print/ 'CNTR: ', cntr
    
  HALT

----------------------------------------------------------
I'm not sure if this is the way I want to go but I thought it might be good experience.
thanks,
lsl49

RE: Using Grip To Edit Text In NX Drafting

You'll need to declare this in your main program ...

Number/ Gpavlu(43)

in your case, you can change the 43 to 5, including the sub-routines. My version controls 43 GPA's.

Paul Phillips
Specialty Engineered Automation
http://www.sea4ug.com

RE: Using Grip To Edit Text In NX Drafting

Change

CODE

ASGNFT/Gpavlu(3),4,IFERR,L1:
To

CODE

ASGNFT/'helios_bold_con',4,IFERR,L1:

The '4' in the above command means that any note using font number 4 will now be changed to helios bold con, is that your intention? If you just want to be sure that helios bold con is available, use the following:

CODE

  ASGNFT/'helios_bold_con',0,IFERR,L1:
  FNUM=&FNTNUM('helios_bold_con')
Passing a '0' into the ASGNFT command just makes sure that the font is in your font table. The &FNTNUM command will return what number it is in your font table. Now you can use the font number (saved as FNUM) to change a note's font selectively.

RE: Using Grip To Edit Text In NX Drafting

(OP)
Thanks Cowski for the info on "ASGNFT".
Paul, I am still getting "Wrong Number of Arguments" on the sub-routines.  

$****************_GPA_SAVE.GRS****************
Proc/ Gpavlu
Number/ Gpavlu(5)

Gpavlu(1)  = &Apsite
Gpavlu(2)  = &Aunit
Gpavlu(3)  = &Cfont
Gpavlu(4)  = &Cnmode
Gpavlu(5)  = &Csize

return

-------------------------------------------------

$***********_GPA_REST.GRS****************
Proc/ Gpavlu
Number/ Gpavlu(5)

&Apsite = Gpavlu(1)
&Aunit  = Gpavlu(2)
&Cfont  = Gpavlu(3)
&Cnmode = Gpavlu(4)
&Csize  = Gpavlu(5)

return

$*********** MAIN PROGRAM *************

ENTITY/L, ents(1000)

NUMBER/ ORIG(3), LNS, RSP, cntr, spot
STRING/ NTXT(132), RTXT(132)

data/ cntr, 0

  inexte/ all
  
  MASK/25  $$DRAFTING OBJECTS

$$  Call Subroutine
      CALL/'_GPA_SAVE'

$$ ****** SET CFONT TO HELIOS_BOLD_CON *******

    ASGNFT/'helios_bold_con',4,IFERR,L1:

L1:
    spot = -1
    L = nexte/ ifend, Z99:
    if/ L == &nulent, jump/ z99:
  
    ORIG(1..3)=&ORIGIN(L)

    $$ RETRIEVE TEXT OF OBJECT
  
    NTXT=&DMTEXT(L)
  
    spot = FNDSTR(NTXT,'<F1>',1)

    ifthen/ spot >= 1
        cntr = cntr + 1
        ents(cntr) = L

        $$              REPLACE TEXT IN NOTE
        RTXT=REPSTR(NTXT,'<F1>','',1)
        RTXT=REPSTR(RTXT,'<F>','',1)
        $$              CREATE NEW NOTE

        NOTE/ORIG(1),ORIG(2),RTXT
        $$ DELETE OLD NOTE
        $$ DELETE/L        $$ we can't delete while cycling
    endif
  
    jump/ L1:
  
Z99:

    $$         done cycling, so now delete all the old notes
    ifthen/ cntr > 0
        delete/ ents(1..cntr)
    endif
    
$$  Call Subroutine
      CALL/'_GPA_REST'

    print/ 'CNTR: ', cntr
    
  HALT

What am I'm doing wrong?
lsl49

RE: Using Grip To Edit Text In NX Drafting

Change your "Number/" declaration to be ...

NUMBER/ ORIG(3), LNS, RSP, cntr, spot, Gpavlu(5)

Then for your two "Call/" statements, they need to be written as ...

CALL/'_GPA_SAVE', Gpavlu

CALL/'_GPA_REST', Gpavlu

Are the sub-routines compiling ?

Paul Phillips
Specialty Engineered Automation
http://www.sea4ug.com

RE: Using Grip To Edit Text In NX Drafting

(OP)
Everything compiles and links now,
thanks,
lsl49

RE: Using Grip To Edit Text In NX Drafting

(OP)
This has been very helpful but this current program does not do exactly what I need. Reference 20 Oct 06 11:47 post.
I just have to keep plugging away at it.

thanks
lsl49

RE: Using Grip To Edit Text In NX Drafting

(OP)
I have been able to edit out the <F1>, <F> and the characters 2122.
I am having a hard time editing multiple lines of text.
Any suggestions?

lsl49

RE: Using Grip To Edit Text In NX Drafting

To edit multiple line notes you will have to loop through the note entity one line at a time. Below is a code snippet I use to determine the number of lines in a note. One pitfall is it does not report blank lines; so if you have a 3 line note - 2 lines of text separated by a blank line - the code will return '2' as the number of lines of text. This is not a problem for me since the notes this routine works with will not have blank lines, but it is something you may need to modify for your needs.

CODE

ENTITY/L
STRING/NTXT(132,132)
NUMBER/LNS,J

  LNS=0
  NTXT=&DMTEXT(L)
  DO/NMLNS:,J,1,132
    IFTHEN/LENF(NTXT(J))>0
      LNS=LNS+1
    ENDIF
  NMLNS:

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