Author Topic: Using a field with filename - path only  (Read 13927 times)

0 Members and 1 Guest are viewing this topic.

KOWBOI

  • Guest
Using a field with filename - path only
« on: May 27, 2010, 10:33:20 AM »
My apologies if this is not in the proper area. Feel free to move it if necessary.

I make use of fields in my title block that populate automatically. I want to add a field using the filename - path only but I would like to show only the last two back slashes in the path.

Instead of showing this:
S:\STONE_APPS\CUSTOMERS\JIM VAUGHN HOMES\24115

I would like to show this:
\JIM VAUGHN HOMES\24115

Is that possible?

Thanks for any and all comments/help.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Using a field with filename - path only
« Reply #1 on: May 27, 2010, 11:29:41 AM »
Use a Diesel expression Field.

eg.
Code: [Select]
$(substr,$(getvar,dwgprefix),[color=red]NUMBER[/color])NUMBER being what you want to cut off.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

LE3

  • Guest
Re: Using a field with filename - path only
« Reply #2 on: May 27, 2010, 11:39:48 AM »
lost my lisp powers some moons ago... but here i go - just to pretend...

Code: [Select]
(defun string-break  (str pat / i j lst)
  (setq i 0)
  (while (setq j (vl-string-search pat str i))
    (setq lst (cons (substr str (1+ i) (- j i)) lst))
    (setq i (+ j (strlen pat))))
  (mapcar (function (lambda (x) (vl-string-trim " " x)))
  (cons (substr str (1+ i)) lst)))
usage:
Code: [Select]
(setq filename "S:\\STONE_APPS\\CUSTOMERS\\JIM VAUGHN HOMES\\24115")
(setq items (reverse (string-break filename "\\")))
;;;(setq backslashes (- (length items) 1))
;;;\JIM VAUGHN HOMES\24115
(setq lsp (strcat "\\" (nth (- (length items) 2) items) "\\" (last items)))
then from field command you can use LispVariable - by selecting your lisp variable there

KOWBOI

  • Guest
Re: Using a field with filename - path only
« Reply #3 on: May 27, 2010, 11:46:58 AM »
Thanks for the input. The number of characters before the last two backslashes changes. Is there a way to count only the backslashes?

I replied before I saw the second response. How exactly would I use the lisp code to set the field to the last two backslashes?
« Last Edit: May 27, 2010, 11:50:11 AM by KOWBOI »

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Using a field with filename - path only
« Reply #4 on: May 27, 2010, 11:51:31 AM »
I replied before I saw the second response. How exactly would I use the lisp code to set the field to the last two backslashes?
Lisp variable Field
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

KOWBOI

  • Guest
Re: Using a field with filename - path only
« Reply #5 on: May 27, 2010, 12:31:23 PM »
I must be missing something. I don't see a field option for lisp variable.

LE3

  • Guest
Re: Using a field with filename - path only
« Reply #6 on: May 27, 2010, 12:33:10 PM »
I must be missing something. I don't see a field option for lisp variable.
from A2010...

KOWBOI

  • Guest
Re: Using a field with filename - path only
« Reply #7 on: May 27, 2010, 01:01:17 PM »
Ok, I'm on 2006 so I don't have the lisp variable option. Guess I should have been specific about which version I was using. Given that I'm on 2006 what are my options now?

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Using a field with filename - path only
« Reply #8 on: May 27, 2010, 01:09:56 PM »
How about setting the string you need to one of USERS1, and using a DIESEL field to retrieve it? Can't think of much else....  :|

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Using a field with filename - path only
« Reply #9 on: May 27, 2010, 01:29:34 PM »
How about setting the string you need to one of USERS1, and using a DIESEL field to retrieve it? Can't think of much else....  :|
Here's an example I did...http://www.cadtutor.net/forum/showthread.php?t=40653
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

KOWBOI

  • Guest
Re: Using a field with filename - path only
« Reply #10 on: May 27, 2010, 01:59:30 PM »
Th IT Nazis here at work have that site blocked as an interest/hobby so I can't view the example. I'd love to see it though, can you post it here?

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Using a field with filename - path only
« Reply #11 on: May 27, 2010, 02:16:11 PM »
Th IT Nazis here at work have that site blocked as an interest/hobby so I can't view the example. I'd love to see it though, can you post it here?

Sure thing. :)

I save the entire page so you could read my post. Both LSP files are also zipped.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

LE3

  • Guest
Re: Using a field with filename - path only
« Reply #12 on: May 27, 2010, 02:50:35 PM »
also, don't remember if RTEXT it is available on A2006, you might see if could be of some help too, maybe

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Using a field with filename - path only
« Reply #13 on: May 27, 2010, 03:18:09 PM »
also, don't remember if RTEXT it is available on A2006, you might see if could be of some help too, maybe
Heck yeah, I still use RText, but it will only accept Diesel.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Using a field with filename - path only
« Reply #14 on: May 27, 2010, 03:25:22 PM »
Without a reactor, I think your first post Alan is the closest we are going to get somehow...