Please see the attached image.
I was wondering if a Diesel Expression Field could be used within a Title Block to display only Positions C, D, E, F, G, & H – Eliminating A, B, J, K, & L.
I am very new to Diesel, but I think I am encountering an issue because the number of characters varies in Positions A, C, E, G, & K.
If this is achievable utilizing Diesel, it would be very helpful if someone could indicate the construction of the code. If not, is there another method?
Hi JIC1118,
if I understood correctly, using DIESEL, I think it will not be possible, due to the number of characters will not be constant, but, using Auto/Visual LISP, something like this should do the trick
(defun my_dwg (dwg / a b c) (if (and (/= "" dwg) (setq a (vl-string-search "-" dwg)) (setq b (vl-string-search " " dwg)) (> (setq c (- b a)) 1) ) (substr dwg (+ 2 a) (1- c)) ) )
_$ (my_dwg "0000000-000-0000-00-000 000000.dwg")
"000-0000-00-000"
_$ (my_dwg "000000-00-0-0-000 0000.dwg")
"00-0-0-000"
_$
I hope this helps
Henrique
I agree that this would not be possible to achieve using DIESEL (refer to this thread for more information in this regard).
Henrique's code offers a good solution, but just to offer a slight alternative, you could also use wcmatch to test the validity of the input string, e.g.:
(defun dwgname ( dwg / pos ) (if (wcmatch dwg "*-*? *") (substr dwg (+ 2 (setq pos (vl-string-position 45 dwg))) (- (vl-string-position 32 dwg nil t) pos 1) ) ) )
(wcmatch dwg "*-*? *")
Nice solution, Lee!
Henrique
Thanks Henrique - your code was equally good!