![]() ![]() I demonstrate this technique with my Layout Field application, which allows you to create a Field Expression referencing the Count property of the Layouts Collection. Therefore, an alternative is to exploit the fact that a Field Expression can actually reference any ActiveX property, not just those displayed in the FIELD command dialog. However, the disadvantage of using global variables to provide this information is that the global variable will only be defined within the document namespace during the active AutoCAD session and will need to be redefined for every session.Īs such, if one of your colleagues or a third-party were to open the drawing file, unless they were also running the code found in your acaddoc.lsp, the *layoutcount* variable would not be defined and consequently the field would not display correctly. (setq *layoutcount* (length (layoutlist)))Ĭopy the above code to your acaddoc.lsp and the *layoutcount* variable will be defined on drawing startup and updated every time the active layout is changed.Īside, it is not necessary to remove Model from the list returned by the layoutlist function, as this function only returns a list of Paperspace layouts. (defun layoutswitched-callback ( rtr arg ) (vlr-miscellaneous-reactor "layoutcount-reactor" (if (= "layoutcount-reactor" (vlr-data rtr)) (foreach grp (vlr-reactors :vlr-miscellaneous-reactor) One possible way around this could be to use a Visual LISP Reactor to update the value of this variable following certain actions.įor example, you could use a Miscellaneous Reactor in the following way to update the variable value when the active layout is changed: ( I guess my code runs only the first time the DWG is opened and then no more.Īs you have gathered, code present in the acaddoc.lsp file will only be evaluated on drawing startup, hence the value of your *LayoutCount* variable will only be correct at the point at which the drawing is first opened. NB - I already checked the option to regen when switching layouts, and forcing update fields raise no results. Does anyone have any clue on how to update this *LayoutCount* variable every time a layout is added/removed from the list? Sad thing is that the field doesn't update until the DWG is reloaded (close and reopen). (lambda (aLayout) (= (strcase aLayout) "MODEL"))) The LISP code is as follows: (setq *LayoutCount* ![]() I created an AcadDoc.lsp file and putted in the autodesk folder. The latter one is not found in built-in fields, so the only way to know it is to use the lisp code (length (layoutlist)). The ultimate goal is creating a text like "Table is the total number of layouts. Task: to have a sheet counter to be used in fields that automatically update their values. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |