Author Topic: how can i get partial directory name with diesel?  (Read 2880 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
how can i get partial directory name with diesel?
« on: June 16, 2011, 10:03:19 AM »
anyone know how i can get this but using diesel instead

Code: [Select]
(substr (vl-Filename-Base (vl-Filename-Directory (getvar "Dwgprefix")))1 6)

i tried the above with diesel but it doesnt work
so i came up with the following, but if the length of the directory name changes, i get undesired results

Code: [Select]
$(SUBSTR, $(substr, $(getvar, dwgprefix), 18, $(-, $(strlen, $(getvar, dwgprefix)), 5)), 2, 6)

any help is appreciated

ronjonp

  • Needs a day job
  • Posts: 7527
Re: how can i get partial directory name with diesel?
« Reply #1 on: June 16, 2011, 10:58:33 AM »
What part of your path are you trying to grab? First folder?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

andrew_nao

  • Guest
Re: how can i get partial directory name with diesel?
« Reply #2 on: June 16, 2011, 01:04:22 PM »
What part of your path are you trying to grab? First folder?

an example would be

F:\DWG\directory\123456 sub directory

im after the "123456" or the first 6 places in the sub dir or whatever dir the dwg is in that i currently have opened

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: how can i get partial directory name with diesel?
« Reply #3 on: June 16, 2011, 01:12:34 PM »
Code: [Select]
(menucmd
 (strcat
  "M=$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 5), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 4), 4),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 6), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 5), 5),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 7), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 6), 6),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 8), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 7), 7),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 9), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 8), 8),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 10), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)),9), 9),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 11), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 10), 10),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 12), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 11), 11),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 13), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 12), 12),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 14), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 13), 13),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 15), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 14), 14),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 16), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 15), 15),)"
 ) ;_  strcat
)

andrew_nao

  • Guest
Re: how can i get partial directory name with diesel?
« Reply #4 on: June 16, 2011, 01:45:33 PM »
Code: [Select]
(menucmd
 (strcat
  "M=$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 5), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 4), 4),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 6), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 5), 5),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 7), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 6), 6),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 8), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 7), 7),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 9), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 8), 8),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 10), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)),9), 9),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 11), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 10), 10),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 12), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 11), 11),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 13), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 12), 12),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 14), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 13), 13),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 15), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 14), 14),)"
  "$(if, $(eq, \\, $(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 16), 1)),$(substr, $(getvar, dwgprefix), $(-, $(strlen, $(getvar, dwgprefix)), 15), 15),)"
 ) ;_  strcat
)



thanks but i need just 1 line if possible im using it as a field inside of a block
i dont think all these will work

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: how can i get partial directory name with diesel?
« Reply #5 on: June 16, 2011, 01:50:43 PM »
thanks but i need just 1 line if possible im using it as a field inside of a block
i dont think all these will work

test to:
Code: [Select]
"$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),5),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),4),4),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),6),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),5),5),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),7),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),6),6),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),8),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),7),7),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),9),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),8),8),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),10),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),9),9),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),11),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),10),10),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),12),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),11),11),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),13),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),12),12),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),14),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),13),13),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),15),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),14),14),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),16),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),15),15),)"

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: how can i get partial directory name with diesel?
« Reply #6 on: June 16, 2011, 04:41:24 PM »
Holy character strings, CodeMan!   :-o
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

andrew_nao

  • Guest
Re: how can i get partial directory name with diesel?
« Reply #7 on: June 17, 2011, 09:55:22 AM »
thanks but i need just 1 line if possible im using it as a field inside of a block
i dont think all these will work

test to:
Code: [Select]
"$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),5),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),4),4),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),6),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),5),5),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),7),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),6),6),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),8),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),7),7),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),9),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),8),8),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),10),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),9),9),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),11),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),10),10),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),12),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),11),11),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),13),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),12),12),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),14),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),13),13),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),15),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),14),14),)$(if,$(eq,\\,$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),16),1)),$(substr,$(getvar,dwgprefix),$(-,$(strlen,$(getvar,dwgprefix)),15),15),)"

thanks but that didnt work either ill just make a lisp to delete the old block and put a new block in and update it that way with attributes
appreciate the help though