• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

fill attributes based on a part of the dwg file name

  • Thread starter Thread starter zintonio
  • Start date Start date

zintonio

Guest
Hello.
I have a cartouche as a block where I have to insert attributes. what I would like to accomplish, if possible, is to fill some fields with a portion of the file name. I give you an example: suppose the file name is called p05-de-g1-h2-10-sch-01-00.dwg
I should fill in the cartiglio attributes according to the file name as follows:
attribute rev: 00
lot attribute: h
attribute section: g
table attribute: g1-h2-10-sch-01
etc. .
Is there a fast method that allows me to do this? thus avoiding editing all one by one with the possibility of making distraction errors.
I hope I've been clear
Thank you.
 
Does the name of the dwg always have the same structure (position and number of characters separated from the dash)?
 
the position of the carattari, that is the formatting, more or less is always that, in some cases the presence of the hyphen is omitted. example:
1) p05-de-g1-h2-10-sch-01-00.dwg
2) p05deg1h210sch0100.dwg
I hope I've been clear.
Thank you.
 
I think that is feasible if you can standardize the namedwg, for example by assigning to characters 11 and 12 the value of "lot attribute".
Otherwise, without logic from one dwg to another, I don't know.
 
ok, the standard in many cases is with the dashes, where each code separated from dashes composes the file name. then you can take as reference the code with the dashes.
 
you have the same location and number of characters. obviously change from file to file but the location and number is always that.
 
Okay, so do this.

1) creates a lisp to assign to variables the text to be assigned to the attribute, in the example you posted may be so
(setq dwg (getvar "dwgname"))

(setq rev (substr dwg 24 2)
(setq lotto (substr dwg 11 2))
(Sectq section (substr dwg 8 2))
(substr dwg 8 15)
where 24 is the beginning character of the string to be saved and 2 is the number of characters that compose it.


2) in the definition of attribute, to the "default" box, as "variable lisp" ---> name of the corresponding variable you have previously saved with the lisp (rev, lot, etc.).

inserting the block into the various dwg, after launching the lisp, attributes will assume the value of the code you need.
 
thanks gp,
I tried and I have to say it's a great solution. I was thinking that I could use the above codes to create a lisp to load to the startup group, so that to every design I open, giving a command (e.g. chargevar), I create the variables for that design, then inserting the block, in the open disgno, the attributes will assume the value of the loaded variable.
You think what I just said is a good method?
Thanks again
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top