dbroada Posted October 17, 2014 Posted October 17, 2014 Our drawing blanks have an MTEXT field linked to the file name. This stops people "SAVEAS" and leaving the new file untraceable. I don't have a problem with this. We also have an ATTRIBUTE that links to the file name without the .dwg extension which is used as the drawing number. I currently don't have a problem with this BUT there is talk that the revision number of the drawing should be incorporated into the file name. This revision number does not form part of the drawing number. What I would like is to display the filename field ignoring either the last 2 characters or up to a set symbol (say an underscore). I am hoping there is a diesel expression I can use but I can't find it at the moment. Our file names will typically be P4GB009999-xx-GA-0001-01_2 but could be quite different so I can't fix the number of characters to display although if I get close it can be modified on a by drawing basis. Quote
steven-g Posted October 17, 2014 Posted October 17, 2014 I think you could do that using a combination of "strlen" and "substr", but it might get complicated. It might be easier to create the file name as an addition of 2 fields and have the value that you need as a seperate item rather than trying to split a longer field. Quote
dbroada Posted October 17, 2014 Author Posted October 17, 2014 I can do this in VB but I don't know what's available in diesel. Unfortunately I'm not sure that we will have much control over the file name itself. One department says that the document name shouldn't contain issue information while our new DMS system needs to keep revisions containing the issue number appended to the document name. We are just caught in the middle and I can see us going back to typing the number in by hand again. Quote
SLW210 Posted October 17, 2014 Posted October 17, 2014 I believe this is the correct one for removing .dwg from filename. Double check, because I use a few different ones for removing different portions. $(substr,$(getvar,"dwgname"),1,$(-,$(strlen,$(getvar,"dwgname")),4)) Quote
dbroada Posted October 17, 2014 Author Posted October 17, 2014 thanks SLW. I'll have a look at that next week. Its poets day today. Quote
SLW210 Posted October 17, 2014 Posted October 17, 2014 Somewhere I have an explanation of what each bit is doing, I'll look for it if you want. Found it GETVAR - short for Get Variable DWGNAME - Variable in AutoCAD which stores the name of the current drawing STRLEN - Returns the length of the string returned by $(getvar, "dwgname") SUBSTR - With user specified options, allows for truncating a string at a specified point Let's assume you are in a drawing named, master.dwg $(getvar, "dwgname") would return "master.dwg" $(strlen,$(getvar,"dwgname")) would return 10 because there are 10 characters in the string which is the drawing name with extension. $(-,$(strlen,$(getvar,"dwgname")),[b]4[/b]) would return 6 because I am subtracting [b]4[/b] from the length of the string. $(substr,$(getvar,"dwgname"),1,$(-,$(strlen,$(getvar,"dwgname")),4)) returns "master". Quote
dbroada Posted October 17, 2014 Author Posted October 17, 2014 I misread the clock. POETS day doesn't start for another hour. but I have looked at your formula and that looks to do the trick. Or at least it did once I realized there was a diesel section in the fields rather than trying to get it to wok as a formula. thanks again. I will look further into this next week. Quote
dbroada Posted October 21, 2014 Author Posted October 21, 2014 back to work today and thanks to SLW, that gives me just what I want. Quote
Voaraghamanthar Posted December 2, 2015 Posted December 2, 2015 I believe this is the correct one for removing .dwg from filename. Double check, because I use a few different ones for removing different portions. $(substr,$(getvar,"dwgname"),1,$(-,$(strlen,$(getvar,"dwgname")),4)) Can I ask a question? With that formula you provided, how can I extract only 151281-100.01 out a file name like this - Drawings-AFC-Electrical-D-CS1-151281-100.01.dwg Quote
op90o Posted December 10, 2021 Posted December 10, 2021 (edited) 在 2015/12/3 在 AM4 點 47 分,Voaraghamanthar 說: 我能問問題嗎? 使用您提供的公式,我如何僅提取 151281-100.01 這樣的文件名 - 輸出-AFC-電氣-D-CS1-151281-100.01.dwg $(substr,$(getvar,"dwgname"),31,$(-,$(strlen,$(getvar,"dwgname")),34)) Edited December 10, 2021 by op90o Quote
Zagorhac Posted September 13 Posted September 13 I know this post is OLD, but if you want more robust code, for example if you later rename a file and you add or remove characters at the end of a filename: %<\AcDiesel $(substr,$(getvar,"dwgname"),36,$(-,$(strlen,$(getvar,"dwgname")),39),99)>% This is the example to display the filename after the 36th character (up to the next 99 characters) Quote
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.