×
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

SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION
3

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

RE: SUBTRACTING ".dwg" FROM DWGNAME EXPRESSION

try this

$(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

(OP)
great thanks that did exactly what i wanted it to do
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

3
DISH,

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

ok, what I need is a diesel expression that can stip out all of the folders except for the last one in the dwgprefix variable.  i.e. dwgprefix returns: P:\projects\2003\client\job#\job#.dwg

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

I kind of knew that would come up.  Reason I wanted to use diesel, was to have rtext pull this into the titleblocks in a project.  How can I use lisp in a block?  I just want the users to insert the titleblock, and have it spit out the project number.  Any help would be great!

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

Thanks estassoc.  The setup is:  I have a dwg file that is the titleblock.  It consists of the geometry for the border and title areas, attributes to enter the checker's name etc. when it is inserted as a block, text, and rtext to give it a plot stamp, and pull in the date.  I currently have an attribute that is the job #.  Users edit the attribute to reflect the job #.  My goal is to remove this possible area spot, by having the block when it is inserted, add the job# automatically.  That is the reason.  If the .dwg was named the job #, this wouldn't be an issue, but the file name is that of the client's project number, which I'm already using as an rtext value, so that the client's project # is auto insterted in the block.  Due to the # of clients, and their profile, I cannot show their titleblock.

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