Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dont understand Diesel

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
210 Views, 9 Replies

Dont understand Diesel

I am trying to place a field in a piece of text that gets the sheet number from the filename. My file name.... 05015-S4.dwg. $(SUBSTR,$(GETVAR,DWGNAME),7,2) Will return S4 and if I have a filename of 05015-S15 I know how to get S15 $(SUBSTR,$(GETVAR,DWGNAME),7,3) I just cant figure out how to write an IF statement to work for both, here is what I have so far: $(IF,$(=,$(SUBSTR,$(GETVAR,DWGNAME),10,1),"."),$(SUBSTR,$(GETVAR,DWGNAME),7,2),$(SUBSTR,$(GETVAR,DWGNAME),7,3)) it returns.... $(IF,??) Rick
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

I haven't used Diesel much at all, but if "substr" works similarly to the way it does in Lisp, you can just omit the ",2" or ",3" at the end, and it will start with the seventh character, and give you the rest of the string, no matter how long that is. -- Kent Cooper "Rick Keller" wrote... > > I am trying to place a field in a piece of text that gets the sheet number > from the filename. > > My file name.... 05015-S4.dwg. > > $(SUBSTR,$(GETVAR,DWGNAME),7,2) > > Will return S4 > > and if I have a filename of 05015-S15 > I know how to get S15 > > $(SUBSTR,$(GETVAR,DWGNAME),7,3) > > I just cant figure out how to write an IF statement to work for both, here > is what I have so far: > > $(IF,$(=,$(SUBSTR,$(GETVAR,DWGNAME),10,1),"."),$(SUBSTR,$(GETVAR,DWGNAME),7,2),$(SUBSTR,$(GETVAR,DWGNAME),7,3)) > > it returns.... $(IF,??) > > Rick
Message 3 of 10
Anonymous
in reply to: Anonymous

That would be fine but I only need 2 or 3 characters. The rest of the string would be S4.dwg etc. But I only want S4 Rick "Kent Cooper, AIA" wrote in message news:423089c1_3@newsprd01... >I haven't used Diesel much at all, but if "substr" works similarly to the >way it does in Lisp, you can just omit the ",2" or ",3" at the end, and it >will start with the seventh character, and give you the rest of the string, >no matter how long that is. > -- > Kent Cooper > > "Rick Keller" wrote... >> >> I am trying to place a field in a piece of text that gets the sheet >> number from the filename. >> >> My file name.... 05015-S4.dwg. >> >> $(SUBSTR,$(GETVAR,DWGNAME),7,2) >> >> Will return S4 >> >> and if I have a filename of 05015-S15 >> I know how to get S15 >> >> $(SUBSTR,$(GETVAR,DWGNAME),7,3) >> >> I just cant figure out how to write an IF statement to work for both, >> here is what I have so far: >> >> $(IF,$(=,$(SUBSTR,$(GETVAR,DWGNAME),10,1),"."),$(SUBSTR,$(GETVAR,DWGNAME),7,2),$(SUBSTR,$(GETVAR,DWGNAME),7,3)) >> >> it returns.... $(IF,??) >> >> Rick > >
Message 4 of 10
Anonymous
in reply to: Anonymous

(I should have thought of that.) Again, in Lisp terms that I hope translate easily enough into Diesel: (setq lengthwithfiletype (- (strlen (getvar "dwgname")) 4));; saves how many characters there are in the drawing name, without the ".dwg" at the end. (setq nameonly (substr (getvar "dwgname") 1 lengthwithfiletype);; saves that name only, without the filetype designation. (substr nameonly 7);; returns that shorter name with its first 6 characters removed, which should be what you're looking for. -- Kent Cooper "Rick Keller" wrote... > That would be fine but I only need 2 or 3 characters. > > The rest of the string would be S4.dwg etc. But I only want S4 > > Rick
Message 5 of 10
Anonymous
in reply to: Anonymous

I understand but I am looking for the Diesel code not lisp code. Rick "Kent Cooper, AIA" wrote in message news:42309890$1_1@newsprd01... > (I should have thought of that.) Again, in Lisp terms that I hope > translate easily enough into Diesel: > > (setq lengthwithfiletype (- (strlen (getvar "dwgname")) 4));; saves how > many characters there are in the drawing name, without the ".dwg" at the > end. > (setq nameonly (substr (getvar "dwgname") 1 lengthwithfiletype);; saves > that name only, without the filetype designation. > (substr nameonly 7);; returns that shorter name with its first 6 > characters removed, which should be what you're looking for. > -- > Kent Cooper > > "Rick Keller" wrote... >> That would be fine but I only need 2 or 3 characters. >> >> The rest of the string would be S4.dwg etc. But I only want S4 >> >> Rick > >
Message 6 of 10
Anonymous
in reply to: Anonymous

Hi Rick How about: $(substr, $(getvar, DWGNAME), 7, $(-, $(strlen, $(getvar, DWGNAME)), 11)) Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch
Message 7 of 10
Anonymous
in reply to: Anonymous

Try eq instead of =, from the help files, = (equal to) If the numbers val1 and val2 are equal, the string returns 1; otherwise, it returns 0. eq If the strings val1 and val2 are identical, the string returns 1; otherwise, it returns 0. So $(IF,$(eq,$(SUBSTR,$(GETVAR,DWGNAME),10,1),"."),$(SUBSTR,$(GETVAR,DWGNAME),7,2),$(SUBSTR,$(GETVAR,DWGNAME),7,3)) should work -- Saludos Marco Jacinto "Rick Keller" escribió en el mensaje news:423086f4_3@newsprd01... > > I am trying to place a field in a piece of text that gets the sheet number > from the filename. > > My file name.... 05015-S4.dwg. > > $(SUBSTR,$(GETVAR,DWGNAME),7,2) > > Will return S4 > > and if I have a filename of 05015-S15 > I know how to get S15 > > $(SUBSTR,$(GETVAR,DWGNAME),7,3) > > I just cant figure out how to write an IF statement to work for both, here > is what I have so far: > > $(IF,$(=,$(SUBSTR,$(GETVAR,DWGNAME),10,1),"."),$(SUBSTR,$(GETVAR,DWGNAME),7,2),$(SUBSTR,$(GETVAR,DWGNAME),7,3)) > > it returns.... $(IF,??) > > > > Rick > > >
Message 8 of 10
Anonymous
in reply to: Anonymous

Almost worked.... I just had to tweak the number a little.... I like the way this looks it is alot shorter than what I had. Once again Juerg you helped me out. Thanks, Rick "Jürg Menzi" wrote in message news:4230A109.C67BD9C@menziengineering.ch... > Hi Rick > > How about: > $(substr, $(getvar, DWGNAME), 7, $(-, $(strlen, $(getvar, DWGNAME)), 11)) > > Cheers > -- > Juerg Menzi > MENZI ENGINEERING GmbH, Switzerland > http://www.menziengineering.ch
Message 9 of 10
Anonymous
in reply to: Anonymous

Thanks Marco, You did indeed fix my problem with what I had. I was looking in the help files and found this statement which is what I was trying to follow: $(if,$(=,$(getvar,cvport),1),mspace,pspace) But I will remember to use eq. Thanks Rick "Marco Jacinto" wrote in message news:4230a192_1@newsprd01... Try eq instead of =, from the help files, = (equal to) If the numbers val1 and val2 are equal, the string returns 1; otherwise, it returns 0. eq If the strings val1 and val2 are identical, the string returns 1; otherwise, it returns 0. So $(IF,$(eq,$(SUBSTR,$(GETVAR,DWGNAME),10,1),"."),$(SUBSTR,$(GETVAR,DWGNAME),7,2),$(SUBSTR,$(GETVAR,DWGNAME),7,3)) should work -- Saludos Marco Jacinto "Rick Keller" escribió en el mensaje news:423086f4_3@newsprd01... > > I am trying to place a field in a piece of text that gets the sheet number > from the filename. > > My file name.... 05015-S4.dwg. > > $(SUBSTR,$(GETVAR,DWGNAME),7,2) > > Will return S4 > > and if I have a filename of 05015-S15 > I know how to get S15 > > $(SUBSTR,$(GETVAR,DWGNAME),7,3) > > I just cant figure out how to write an IF statement to work for both, here > is what I have so far: > > $(IF,$(=,$(SUBSTR,$(GETVAR,DWGNAME),10,1),"."),$(SUBSTR,$(GETVAR,DWGNAME),7,2),$(SUBSTR,$(GETVAR,DWGNAME),7,3)) > > it returns.... $(IF,??) > > > > Rick > > >
Message 10 of 10
Anonymous
in reply to: Anonymous

Glad to help you...¦-) Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost