Author Topic: Diesel expression for field help  (Read 1571 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Bull Frog
  • Posts: 479
Diesel expression for field help
« on: October 18, 2018, 11:40:14 AM »
We're looking to create fields in our drawings.
This gives the current tab name/number.... is there a was to remove leading zero if it exists?

Code: [Select]
%<\AcVar ctab \f "%tc1">%
Thanks

Lee Mac

  • Seagull
  • Posts: 12514
  • London, England
Re: Diesel expression for field help
« Reply #1 on: October 18, 2018, 01:12:03 PM »
You could use a DIESEL field with the code:
Code - Auto/Visual Lisp: [Select]
  1. $(if,$(=,0,$(substr,$(getvar,ctab),1,1)),$(substr,$(getvar,ctab),2),$(getvar,ctab))

Note that this will remove one leading zero at most, and will return an empty string for layouts named "0".

tombu

  • Bull Frog
  • Posts: 246
  • ByLayer=>Not0
Re: Diesel expression for field help
« Reply #2 on: October 18, 2018, 01:46:09 PM »
Not knowing what you want to do with it there may be better solutions out there.
Two of Lee Mac routines that may be of use:
http://lee-mac.com/layoutfield.html
This program defines a set of commands which enable the user to populate a selected annotation object (Text, MText, Attribute) with a field expression referencing the name and position of the layout in which the object resides.

Contrary to the typical use of the CTAB system variable, as offered by the standard AutoCAD FIELD command, the field expressions generated by this program directly reference the ActiveX Layout object within the Layouts Collection, and therefore do not depend on the layout being current in order to display the correct output.

This is particularly advantageous when using the DATAEXTRACTION command to retrieve data from multi-layout drawings, as field expressions which reference the CTAB system variable will yield the same value for every layout when processed by this command.

http://www.lee-mac.com/tabsort.html
A program designed with the intention to aid in the organisation of layout tabs in a drawing, the program enables the user to organise each layout tab using intuitively engineered buttons to move selected tabs up/down or to the top/bottom of the tab order.

The program also offers the ability to rename a layout tab by double-clicking on its entry in the list displayed, and furthermore add a prefix and/or suffix to selected/every layout tab.

A facility is also provided to add & delete layout tabs, and also sort the tabs into alphabetical, numerical, or architectural order; or reverse the order currently displayed.

A Find & Replace functionality is also offered to allow the user to quickly replace a text string in multiple layout tabs.

The user may also copy selected layout tabs, or set the selected entry as the current drawing layout.

A Help Dialog may be shown upon pressing H at the Main Dialog interface.

Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

Biscuits

  • Bull Frog
  • Posts: 479
Re: Diesel expression for field help
« Reply #3 on: October 22, 2018, 02:21:36 PM »
Thank you gentlemen. Both ideas work great. I really appreciate your efforts. Sorry I didn't get back to you guys sooner...been under the weather last few days.

jaysonlavarias

  • Mosquito
  • Posts: 2
Re: Diesel expression for field help
« Reply #4 on: July 07, 2021, 12:38:48 PM »
Hi I have the same problem. I'm combining Filename and Ctab on a single attribute. Say AB1-1, where AB is the filename and 1 is the current tab and I'm using multiple layout on a single drawing. Upon running Lisp to convert all fields to text, the current layout number is reflected in all layouts. I've tried Lee Macs Layout Field. It works great...I'm not having issues running field to text lisp..but I need to combine it with a filename in a single attribute.. Thank you in advance for all of your responses.

BIGAL

  • Swamp Rat
  • Posts: 831
  • 30 + years of using Autocad
Re: Diesel expression for field help
« Reply #5 on: July 07, 2021, 10:19:29 PM »
It may be easier to run a update title block that goes through the layouts and changes an atttribute. Have found in the past with fields in this type of situation each field will be different as it reads the layout id, hence why you got a-1 b-1 c-1. Others will say use sheetsets. Also do you want layout name or a number.

Happy to provide something have a few Update title block lisps. Post a dwg etc.

A man who never made a mistake never made anything

ronjonp

  • Needs a day job
  • Posts: 7327
Re: Diesel expression for field help
« Reply #6 on: July 08, 2021, 01:12:06 PM »
Hi I have the same problem. I'm combining Filename and Ctab on a single attribute. Say AB1-1, where AB is the filename and 1 is the current tab and I'm using multiple layout on a single drawing. Upon running Lisp to convert all fields to text, the current layout number is reflected in all layouts. I've tried Lee Macs Layout Field. It works great...I'm not having issues running field to text lisp..but I need to combine it with a filename in a single attribute.. Thank you in advance for all of your responses.
This does not work for you?
Code - Auto/Visual Lisp: [Select]
  1. %<\AcVar Filename \f "%fn2">%-%<\AcVar ctab>%

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

jaysonlavarias

  • Mosquito
  • Posts: 2
Re: Diesel expression for field help
« Reply #7 on: July 10, 2021, 05:48:19 PM »
Hi, thank you for your responses. I've attached a sample drawing that I'm working on, the First one with filename BS1 as the original file and the second one BS1_output, as the result upon running the Field to text lisp, I've acquired online. Notice that the output file shows the same output on the layout number. I've also attached the lisp that I'm using to convert fields to text.

Hoping to hear from you soon. Have a great day.