Jump to content

shortening fields in attributes


dbroada

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. :(

Link to comment
Share on other sites

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))

Link to comment
Share on other sites

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".

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 year later...
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

Link to comment
Share on other sites

  • 6 years later...
在 2015/12/3 在 AM4 點 47 分,Voaraghamanthar 說:

 

我能問問題嗎?

使用您提供的公式,我如何僅提取 151281-100.01 這樣的文件名 -

輸出-AFC-電氣-D-CS1-151281-100.01.dwg

$(substr,$(getvar,"dwgname"),31,$(-,$(strlen,$(getvar,"dwgname")),34))
 

2021.12.10_n7.png

Edited by op90o
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...