SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
(OP)
Has anyone found out how to get rid of the extension ".dwg" from the rtext->diesel expresion: $(getvar,"dwgname").
The drawing file name comes out in the drawing but I don't really want to show what file type it is.
Any help out there would be appreciated
The drawing file name comes out in the drawing but I don't really want to show what file type it is.
Any help out there would be appreciated





RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
$(substr,$(getvar,"dwgname"),1,$(-,$(strlen,$(getvar,"dwgname")),4))
RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
Lothar
Win NT4.0 (SP6),
ACAD 2000i (SP2), ADT 3.0 (SP3),
ACAD 2002, ADT 3.3,
OCÈ 5200
RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
could you now explain to me how it does this. I am new to diesel expresions and am still learning. Is the 4 in the end to do with flags?
RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
GETVAR - short for Get Variable
DWGNAME - Variable in AutoCAD which stores the name of the current drawing
STRLEN - Returns the length of the string returned by $(getvar, "dwgname")
SUBSTR - With user specified options, allows for truncating a string at a specified point
To use an example, let's assume you are in a drawing named, 100-03-master.dwg
$(getvar, "dwgname") would return "100-03-master.dwg"
$(strlen,$(getvar,"dwgname")) would return 17 because there are 17 characters in the string which is the drawing name with extension
$(-,$(strlen,$(getvar,"dwgname")),4) would return 13 because I am subtracting 4 from the length of the string.
$(substr,$(getvar,"dwgname"),1,$(-,$(strlen,$(getvar,"dwgname")),4)) returns "100-03-master". The way it does this is as follows:
1. It first gets the drawing name with extension
2. It then gets the length of the drawing name with extension
3. It then returns the length obtained minus 4 because of the 4 characters in ".dwg"
4. Now with the Substr function, it starts at character 1 and goes 13 steps through the string and returns "100-03-master"
The AutoLISP equivalent of this is as follows:
(substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4))
If you want to store that information to a user specified variable, you might use:
(setq dwg-name (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)))
Hope this helps.
Jeff Foster, PE
CE Group, Inc.
Apex, NC
RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
I want to strip out everything but the job#. This is a little more complicated than mathmatical solutions, since the path length can vary as will all of the lengths of the folder names. The only absolute in every senario is "P:\projects" I can strip it out easy enough. Job#s vary in length as do dwg names. Any suggestions?
RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
Plight,
It's easier to use lisp.
RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
Plight,
Is the project number an attribute in the
titleblock? What's the tagname or attribute
info? What's the name of the titleblock?
Rtext is limited compared to lisp since your
drawing prefix (string length) is varaible.
In RTEXT, theres' no "while" & "repeat" function
which you need in order to extract the job # from
the drawing prefix. It would be nice if an image
of the block showung the attribute is available.
RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION