Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Grip To Edit Text In NX Drafting 5

Status
Not open for further replies.

lsl49

Mechanical
Sep 26, 2004
33
0
0
US
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
 
Replies continue below

Recommended for you

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

 
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.
 
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
 
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
 
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.
 
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
 
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
 
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
 
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
 
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:
 
Status
Not open for further replies.
Back
Top