Leading Zero in computed attribute value

Leading Zero in computed attribute value

mbickelVMG55
Enthusiast Enthusiast
3,086 Views
11 Replies
Message 1 of 12

Leading Zero in computed attribute value

mbickelVMG55
Enthusiast
Enthusiast

I am trying to create a simple transform that would add a leading zero in front of integers from 1-9. (as in, 01, 02, etc.). This is for a very simple application: a paperspace match line block that is automatically generated but could be manually updated or manually overwritten.

 

I can generate the desired number in a few ways, but I CANNOT GET A LEADING ZERO in front of single digit integers.

 

I have tried many workarounds. The most frustrating part is that autocad has options for formatting formula output. There are hundreds of possibilities simply with the formatting. But the closest I have found is to divide by 10 and make the decimal delimeter a space. That leaves a space in the numbers (0 1, 0 2, etc.).

 

I have had success with property sets. However, they can only be referenced in labels that appear in model space. I have solved this problem where plan production matchlines can be used. But for our biggest client, I need a dumber matchline in paper space. There will be a page template that has a plus 1 and minus 1 match line. Additional matchlines could be added or copied. However, if the entire layout is copied and re-named, the default references would be the previous and subsequent sheets.

 

I am posting a drawing with two blocks. One computes the previous page in a diesel expression. This one is hard coded to the previous sheet only. The other uses a custom block variable to add sheets to the existing. Thus, one block could make all the matchlines. But neither can handle the leading zero.

 

I have tried using a lookup table to connect 1 to 01, 2 to 02, etc.  But apparently attributes can't be referenced; only parameters can. And it seems parameters can't have computations. 

 

Any help would be much appreciated. Thanks,

0 Likes
Accepted solutions (1)
3,087 Views
11 Replies
Replies (11)
Message 2 of 12

Libbya
Mentor
Mentor

The following is not specifically a means to add a leading zero to one-digit numbers, but it seems like it solves the issue you are describing.

 

Are you using sheet sets?  If so, then why not use  a sheet number field ?  I use matchlines in sets (using ACA) and that's what I do.  Drag the matchline block to the appropriate sheet/view to link the block to that view/sheet number.  Any consequent changes to any of the sheet numbers automagically update in the matchline blocks.  The leading zero would just be part of the sheet number text string.  

0 Likes
Message 3 of 12

mbickelVMG55
Enthusiast
Enthusiast

When I reference a sheet set variable in a field, I can only reference the current sheet number. Not the previous or subsequent sheet number, or any other number…? If this is incorrect, please explain how to reference the other sheets. The previous or subsequent number can be referenced in a match line label; however the match line label can only appear in model space.

 

are you referencing a process involving call out blocks? I have read some of that, but it seems each block would need  to be linked manually. If so, it sounds   more complicated than just manually typing the sheet  numbers.

 

The purpose is to give the people creating the sheets fewer things to think about, while having equal or better reliability.

0 Likes
Message 4 of 12

Libbya
Mentor
Mentor

If using sheet sets in base AutoCAD then you can use the sheet set field to reference a specific sheet and sheet number in a set.  The process is indeed cumbersome.  There may be an easier way, but I have done very little in base AutoCAD.

 

If using one of the verticals (e.g. ACA) which incorporates Project Navigator, then it is just a matter of opening the sheets tab in PN and dragging a block to the correct sheet to link to 'sheet set placeholder' fields that are within the block.  That method is quite simple and easy. 

 

Those fields work in either model space or paper space.   

0 Likes
Message 5 of 12

mbickelVMG55
Enthusiast
Enthusiast
I am using civil 3-D, which does have sheet set placeholder fields. But when I read about this, it still seemed like a cumbersome process- because the default placeholder would be to the same sheet, not to a different sheet. The goal is for someone else who knows nothing about blocks to copy the sheet 20 times, either manual copying or using the plan production tools. They are currently used to mtext match lines with no intelligence. If they do not understand something new immediately they will simply use mtext.
0 Likes
Message 6 of 12

Libbya
Mentor
Mentor

The 'sheetsetplaceholder' fields do not automatically adopt the property from the sheet they are placed on.  The 'current sheetXXX' fields are the ones that automatically adopt the sheet they are placed on.  For the 'sheetsetplaceholder' fields, you drag the block to the sheet view for linking.  It is a very simple process, IMO, and avoids issues if the sheet numbers are later changed.  

0 Likes
Message 7 of 12

h_s_walker
Mentor
Mentor

If you are naming your tabs 01, 02 etc it can be done

Credit goes to the following link

Solved: Re: Diesel Expression that reads the Layout tab?! - Autodesk Community - Civil 3D

 

See the attached drawing

 

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 8 of 12

h_s_walker
Mentor
Mentor

Updated drawing attached. Just put the 0 in as a prefix in the "Additional Format" section of the field.

 

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 9 of 12

mbickelVMG55
Enthusiast
Enthusiast

I went down this road earlier this year. The process is outlined here:

 

https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2021/ENU/AutoC... 

 

Unfortunately, it requires naming all the views, which we have never done. Then, dragging the reference. So, two steps to avoid 1 step (and potentially more later). Maybe if the view naming was automated or done by an extension this could be the way to go. 

Also, there are some in my company that will never use sheet sets. So I really do want to do this in paper space.

0 Likes
Message 10 of 12

mbickelVMG55
Enthusiast
Enthusiast

Good thought on the formatting, but prefix puts a zero in front of everything. Thus, "17" becomes "017", when it should be just "17".

 

Consider two numbers, 6 and 17. In (formula) formatting, I can divide by 100, but then I have "0.06" and "0.17". I cannot get rid of the first zero and the decimal. I could add 100, giving me "106" and "117", thus normalizing the number of digits and populating the ones column. Then I simply need to hide the "1"... but masks are not an option. (That is tangential, but important. Masks add significant manual steps at the end of a process). "Additional Formatting" has an option to hide leading zeros, but it will not hide the zero before a decimal.

 

Diesel is somewhat  promising. The steps would be:

1. Get the CTAB value (eval combined w/ getvar)

2. Add or subtract a number

3. Add 100 to ensure at least 3 characters

4. Convert value back to text

5. Truncate to take the last two characters

 

I have done steps 1-3, and believe 4 and 5 can be done. BUT, it still can only add or subtract the value in the diesel expression. Ideally, I would be able to get a custom block variable or even a standard block property such as z position and put it into the expression. 

Can diesel get block variables or block placeholder variables?  What would their names be? If so, it would be 4-5 nested diesel expressions.

0 Likes
Message 11 of 12

h_s_walker
Mentor
Mentor

The only other way I can think of getting something like that to work, but I'm not sure how to in AutoCAD is to use "0#" as a formatting code for the number.

In Excel this would put a 0 in front of the number if it's less than 10, but anything 10 and above it doesn't.

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 12 of 12

mbickelVMG55
Enthusiast
Enthusiast
Accepted solution

I have something here that does what I am trying to do (using diesel). The entire sheet can be copied or used as a P&P template, and the match lines will adjust. I put the text portion of the block into an attribute to give an override option, even though diesel expressions are not required to be in an attribute field. The expression reads the layout name, converts it to a number, adds or subtracts 1, adds 100 to force a 3-digit number, then truncates the first number.

 

The one thing I wish I could do is make the expression dependent on a user defined property. With diesel, I can grab a system variable but not a block placeholder. IF I could grab a block placeholder, I could use a single block that added or subtracted any number of sheets from the current layout name. In the current drawing, the two blocks are have the same definition with different default values.

0 Likes