Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Fields Questions

8 REPLIES 8
Reply
Message 1 of 9
stanovb
1001 Views, 8 Replies

Custom Fields Questions

I have two questions about custom fields. In one of our titleblocks we have a place that says this is sheet 1 of 4. Is there a way to do this as a custom field? Could a field determine that the tab is the first one & that there are 4 tabs in the drawing? I have not gotten into sheet sets but i plan on doing that soon. This particular drawing has all of the tabs that i was referring to. The other question is in our drawn by area i have a field set to look at the login name but we abbreviate the name so i was wondering if a field could take the login name & assign an abbreviation to it. For example if i had a user named Bill Taylor could i make the field say "BT"

8 REPLIES 8
Message 2 of 9

You can set up two custom properties in your drawing templates, sheet and initials.  Then you can call on those when you insert field under documents and it will display the values you input in the drawing properties.

 

In your title block where you want this text do the following. Insert a field select other and then diesel and put this code in the window to populate the first portion.

"Sheet "$(substr,$(getvar,ctab),7,2))" of "

Hit ok then insert another field select document and then your custom field sheet.

 

Note the 7,2 in the diesel expression is assuming your tabs are named layout 1, layout 2 etc.  This omits the first 7 characters and returns up to two following, so if you had over 100 sheets change the 2 to 3.

Message 3 of 9

When you say custom properties are you referring to sheet sets? I do not have any sheet sets created. I need to learn about them as i have not worked with them very often. Our tabs are named the same as the name of the sheets that we are plotting. For instance, our floor plan is usually named something like "A1.0" so our tab would be named the same. Smometimes we have multiple drawings that have various numbers of drawings in them so sheet sets could be very useful. Someone has giving me a document on sheet sets which i need to go through & learn how to set them up & use them. This particular drawing might have 1 to 4 tabs in it so i was trying to figure out a way to have autocad recognize the first tab & also how many tabs are in the drawing. Do tabs have handles like a block or other entities that you could reference with a field?

Message 4 of 9

File / drawing properties then click on custom properties add one, name it and give it a value.  Yes "ctab" is a system varible that will return what you have named your tab.  If you are going to use sheet sets they have several field values related to them that might be useful in automating more of your titleblock.  Theres a bit more to do what you're asking as far as starting at one, sorting the layoutlist and returning a number value field has a bit more programing to it than I know but maybe someone here will help.

Message 5 of 9

Yeah, thanks alot. I need to learn more about sheet sets. I really think they could be very useful. I think ctab is for current tab if im not mistaken. you've been very helpful. Thank you.

Message 6 of 9
Lee_Mac
in reply to: stanovb

Since a Field Expression can actually reference any ActiveX Property of any VLA-Object, here is another way to create the required Field:

 

(defun c:sheetfield ( / att obj )
    (while
        (progn (setvar 'errno 0) (setq att (car (nentsel "\nSelect attribute: ")))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (null att) nil)
                (   (/= "ATTRIB" (cdr (assoc 0 (entget att))))
                    (princ "\nSelected object is not an attribute.")
                )
            )
        )
    )
    (if (= 'ename (type att))
        (progn
            (vla-put-textstring (setq obj (vlax-ename->vla-object att))
                (strcat
                    "%<\\AcObjProp Object(%<\\_ObjId "
                    (LM:objectid (vla-get-layout (LM:getowner (LM:getowner obj))))
                    ">%).TabOrder>%"
                )
            )
            (vla-regen (LM:acdoc) acactiveviewport)
        )
    )
    (princ)
)

;; Get Owner -  Lee Mac
;; A wrapper for the objectidtoobject method & ownerid property to enable
;; compatibility with 32-bit & 64-bit systems

(defun LM:getowner ( obj )
    (eval
        (list 'defun 'LM:getowner '( obj )
            (if
                (and
                    (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
                    (vlax-method-applicable-p obj 'ownerid32)
                )
                (list 'vla-objectidtoobject32 (LM:acdoc) '(vla-get-ownerid32 obj))
                (list 'vla-objectidtoobject   (LM:acdoc) '(vla-get-ownerid   obj))
            )
        )
    )
    (LM:getowner obj)
)

;; ObjectID  -  Lee Mac
;; Returns a string containing the ObjectID of a supplied VLA-Object
;; Compatible with 32-bit & 64-bit systems

(defun LM:objectid ( obj )
    (eval
        (list 'defun 'LM:objectid '( obj )
            (if
                (and
                    (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
                    (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)
                )
                (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
               '(itoa (vla-get-objectid obj))
            )
        )
    )
    (LM:objectid obj)
)

;; Active Document  -  Lee Mac
;; Returns the VLA Active Document Object

(defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc)
)

(vl-load-com) (princ)

 

Message 7 of 9
sovby
in reply to: Lee_Mac

Thanks Lee, that looks pretty complicated. Where would i enter all that stuff in? Would i add that in as a field expression? I've been looking at sheet sets over the last few days & i'm really very excited about the possibilities. This could be extremely helpful to my company. Right now we are printed in what i would call prehistoric ways. We have a lisp routine to make the plots but sheet sets seem to be 1000 times better. All of the things that you can do with sheet sets makes me wonder why have i been plotting & managing drawings without this.

Message 8 of 9
Lee_Mac
in reply to: sovby

Hi sovby,

 

Sorry, the code I have posted is AutoLISP code which defines a program to automatically generate the required Field expression within a selected block attribute.

 

To understand how to run the program, please follow my tutorial here.

 

If you get stuck, just ask.

 

Lee

Message 9 of 9

Hi,

 

We have been using sheet sets with custom sheet fields for the past 4 years.  I just got a client template that uses document custom properties in the title block. 

 

Is this just an old way of doing this?

Can these custom document fields be edited without opening the individual drawings?

 

Thanks

Thanks,

Denis

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost