vuxvix Posted September 27, 2021 Share Posted September 27, 2021 (edited) Hi! My file name form: AAAA-BBBB-CCCC Inside: AAAA and CCC was fixed BBBB is the name of each drawing. I'm using the Diesel function to insert a name (BBBB) into a drawing canvas. $(SUBSTR,$(GETVAR,DWGNAME),No.1,$(-,$(STRLEN,$(GETVAR,DWGNAME)),No.2)) Inside: No.1: The start letter of the string No.2: the starting letter of the omitted part. Problem: Because BBBB item is not fixed number of letters. Is there any way to remove the CCCC part. By way of counting down from the end? Thank you very much R-03-06_4FloorPlan (Drafting).dwg Edited October 5, 2021 by vuxvix Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 28, 2021 Share Posted September 28, 2021 You have full autocad ? A lisp will probably do easier, wcmatch comes to mind and look for "-" and split into a list. AAAA-BBBB-CCCC ; thanks to Lee-mac for this defun ; www.lee-mac.com ; 44 is comma, 32 is space, 45 is - (defun _csv->lst ( str / pos ) (if (setq pos (vl-string-position 45 str)) (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2)))) (list str) ) ) (setq ans (_CSV->LST "AAA-BBBB-CCC")) ("AAA" "BBBB" "CCC") Then strcat a new answer. Quote Link to comment Share on other sites More sharing options...
dexus Posted September 30, 2021 Share Posted September 30, 2021 Working together with the function Bigal posted, you can save the variable in a custom property. I use the following function to create that custom property in each drawing. (defun setCustomDwgProp (key value / summaryInfo) (setq summaryInfo (vla-get-summaryInfo (vla-get-activeDocument (vlax-get-acad-object)))) (if (getCustomDwgProp key) (vla-setCustomByKey summaryInfo key value) (vla-addCustomInfo summaryInfo key value) ) ) You can set the variable like this: (setCustomDwgProp "Drawingname" "BBBB") and you can reference them in a field like this: %<\AcVar CustomDP.DrawingName>% You can also see all the set properties in File->Drawing Properties->Custom. Maybe putting this all together will be a solution for you. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 1, 2021 Share Posted October 1, 2021 There is a lot more to this post over at autodesk/forums became a lot more complicated. Quote Link to comment Share on other sites More sharing options...
vuxvix Posted October 4, 2021 Author Share Posted October 4, 2021 (edited) Hi @BIGAL @Dexus Sorry for not being able to reply for a while. Because the question is uploaded every day a lot. And there are not many people who can help. So I try to find support in many places. Apologies if this is not appropriate. Since my work environment mostly uses Autocad LT, I'm not sure if there is any problem with displaying the Fields in other computers. Also I have tried the lisp code, besides creating lisp file, editing lisp is beyond my ability. What can I do to use it. Ps:I double checked my Field in the post. actually the omitted part has been counted down from the end. I noticed {.dwg} is numbered :12-9 respectively. The coincidence of the length of the string of letters in the file name confused me. Apologies for this silliness. Edited October 4, 2021 by vuxvix Quote Link to comment Share on other sites More sharing options...
steven-g Posted October 5, 2021 Share Posted October 5, 2021 If you want to use this in LT then Lisp is not an option. If you do use full AutoCAD and Lisp to create 'fields' then they should still be correct for someone who opens the file with LT it is just LT cannot create the fields using Lisp. It would help if you could post an example file showing what you are trying to achieve. Quote Link to comment Share on other sites More sharing options...
vuxvix Posted October 5, 2021 Author Share Posted October 5, 2021 Hi @steven-g I have edited this post. It includes an example. Thank you very much Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 7, 2021 Share Posted October 7, 2021 On 9/27/2021 at 7:32 AM, vuxvix said: My file name form: AAAA-BBBB-CCCC Inside: AAAA and CCC was fixed If "AAAA" and "CCCC" are of fixed length as you state above (and let's say that each are 4 characters), you can subtract these lengths plus the delimiter (i.e. 10 characters) from the overall string length to obtain the length of the "BBBB" section, e.g.: $(substr,$(getvar,dwgname),6,$(-,$(strlen,$(getvar,dwgname)),10)) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 7, 2021 Share Posted October 7, 2021 Lee have a look over at forums/autodesk lots more comments. Quote Link to comment Share on other sites More sharing options...
vuxvix Posted October 7, 2021 Author Share Posted October 7, 2021 Hi all! Forgive me, because actually the problem in the topic is because I misunderstood how to count the number of the No.2 value. I have summarized the problem content in the attached file (filename and examples). Also I want to ask 2 questions: -filenames with {CCCC} are not fixed length-eg: _yyyyMMdd ;-yyMMdd. Is it possible to remove it!? -In the drawing frame also includes the Layout number: I used LeeMac's Lisp layout Field. Looks like it takes the value on each specific layout. So still execute the command on each layout. As I see on the forum, autocad doesn't support it at the moment. Is there any lisp that does insert prefix sequence number? I use LeeMac's Tabsort, but it only inserts a specific value. Thanks for all the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.