TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Biscuits on October 18, 2018, 11:40:14 AM

Title: Diesel expression for field help
Post by: Biscuits 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
Title: Re: Diesel expression for field help
Post by: Lee Mac 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".
Title: Re: Diesel expression for field help
Post by: tombu 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.

Title: Re: Diesel expression for field help
Post by: Biscuits 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.
Title: Re: Diesel expression for field help
Post by: jaysonlavarias 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.
Title: Re: Diesel expression for field help
Post by: BIGAL 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.

Title: Re: Diesel expression for field help
Post by: ronjonp 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>%
Title: Re: Diesel expression for field help
Post by: jaysonlavarias 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.