AutoCAD Visual LISP / AutoLISP :: Can Fields Reference Other Fields On Layout
Jul 11, 2012
I was wondering if it was possible to say have a cover sheet of a project with fields and then have the other sheets in the project have their fields populate using information from cover sheet?
I am trying to add a reactor, where if the object i move or copy is s a block of a certain name, then i would like to run update field on the last object (being copied) or the object being moved.
(defun getLayout (pos / result cLayout layouts^ i len) ; pos = -1 return previuous layout name ; pos = 0 return current layout name ; pos = 1 return next layout name (cond ((zerop pos) (setq result (getvar "ctab")) ); case
[code]...
which basically returns either the current, previous or next tab name depending on what you call up. Any way to link this lisp to a field? I am doing some plan and profile drawings which contain match lines I would like to have the match line text automated. For example if I'm on layout called PP02 there would be two match lines in the drawing one would read MATCH LINE PP01 and the other would read MATCH LINE PP03 this lisp routine returns the correct variable but how do I loink this to a fiels?
I've successfully written a lisp routine to insert a scale bar dynamic block with attributes, gather the object id of a user selected viewport, and write fields to attributes for each of the numbers across the top of the typical scale bar as well as the scale name, for both architectural and civil units. I'm trying to come up with a similar dynamic blocklisp routine combination to do the same with view titles, and the associated scale callout. The catch in this case is that I'd like to display the scale as "NTS" if it isn't a proper scale. The "standardscale" object property option in the field dialog box gives me almost exactly what I want, except that non-standard scales are displayed as "CUSTOM" as opposed to "NTS". Moreover, I’d like this to update on the fly, if the viewport scale changes, the scale callout needs to change also, back and forth from “NTS” to a standard scale if need be.
is there a way to change that (CUSTOM NTS)? My research online seems to indicate that the nuts and bolts of fields are deeply rooted in ObjectARX, which is something I know very little about?
The natural followup to that question is, if I can't change "CUSTOM" to read "NTS", is there a way to wrangle this whole thing with reactors? I'm envisioning object reactors, created as a part of the insertion routine, for each individual instance of the block (there could very well be several in a layout, and multiple layouts in detail drawings), that would call another routine to evaluate the viewport scale, and if it didn’t match a list of standard scales, write NTS to the attribute. My issue is that reactors seem to only associate with one object, in this case that’d be the viewport, the reaction would cause the reactor to call the routine, but how does the routine know which block to update? Is there something from the viewport properties that I can add to the block name (or some other property) which will allow the routine to figure out which block to edit?
I’ve attached my scale bar code, and block, as reference context for how I plan to set the view title up.
I was hoping to use find and replace "#" with broken fields in the drawing. but it will not find the # value that the field creates when it is broken. Is the only way to find a broken field a visual check? or is there another way I am not aware of?
I've been up and down the forums looking for some direction or programming code for this to no avail.
What I'd like to do is edit a table where the cells are populated with fields. I'd like to copy the last row of the table to a new row (fields and all), then change the fields of the row I copied FROM to text, and lock those cells.
I'd like to copy this row including the fields to a new row beneath it. Then edit the cells of the first row to change the fields to text, and then finally lock the cells of the first row so that only the new row would update when the field properties change. Eventually they will be populated with data from the Vault..
Convert Fields to text in my Title Block. I want to change some specific attributes only to convert into texts in my title block ( "MODE_A3" is my Title Block name).
For example in "MODE_A3" block having lots of tags like TAG1, TAG2, TAG3 upto TAG10 with fields. I need to change TAG3, TAG4, & TAG5 attribute fields into texts in all layouts.
I am looking for a way to create a master list of construction notes then use blocks attributes with fields to link to that master list. That way if the master list changed the note bubbles would change as well.
Sheet sets are being used with this project but I can't think of a way to make it work with the existing sheet set technology.
Is there any way to make print merge fields relative in position to other fields or to non-variable text.
For example if I am doing address labels and I have fields for City and State:
Their positions are absolute, and the state ends up overwriting the city for long city text, as does the comma.
What I want is for the comma to follow the last letter of the city, and then state to follow that.
And yes, I realize that I can combine all three into one field, but I am asking this as a general usage of the feature. One doesn't always have control over the source.
I just opened up a project Sheet Set that i haven't worked on in a while, and all of my layout pages have a series of "#" in place of the fields. For example, the name of my viewport should read "Head Detail", which is the name given to that view in the Sheet Set Manager, but instead reads "##############". This also happens with my view numbers, callout bubbles, etc.
However, the information in my title block is still intact. For example, the Project Name, Client Name, Page Number, etc. all read the correct values.
I tried opening the drawings in Reference Manager, but I see no alerts or errors. I have had this happen before in previous versions going back to at least 2010, but they have always been small projects and I just recreated the views and callouts. This is a large project however, and redoing this will cost hours, if not days of extra work.
In examining the fields, it seems like the problem fields are those defined by the SheetSetPlaceholder Filed Name, and the Placeholder type is irrelevent; they are all broken. For other Field Names, for example CurrentSheetNumber, the references still work.
BLOCK REFERENCE Layer: "TWC Dim" Space: Model space Handle = 27879
The above result from LIST > 'Last' ... gave only the above result.
We have a project... granted, the requirement is to model 1.6 million feet from world origin... I know that AutocAD can have issues with this... and we have certainly had issues on this job that can be attributed to this... BUT WHAT ABOUT THIS ISSUE?
When anything is INSERTed into this drawing file, or from this dwg file... it doesn't seem to show up... no command line errors, no OFF or Frozen layers, no objects Isolated, no indication at all that there was a problem... except that nothing showed up.
This was used to find the issue. List the last object added to the database. Then paste to original coordinates (NOT PASTE AS BLOCK)
Command: list Select objects: l 1 found Select objects:
[Code] .....
No more info.. no block name, no Handle, no Insertion point x,y,z... no scale factors, none of the normal info that should accompany the BLOCK REFERENCE LIST output.
Several Audits were done, and Recover... this reported fixing Invalid Block Refs... we even rebuilt the dwg in a blank dwg file... but still object INSERTed with this same behaviour.
Is there any way to grab the Object ID or name from a layout tab to use in a field? I wish to link the layout name to a callout block so that if the layout tab changes position and name (inserting a new tab), the call out block will update no matter what page it is on. Without using the Sheet Set manager.
I am trying to write a LISP that does the following:
-Open drawing
-Saveas as NEW drawing based on certain criteria from DCL menu
-Deletes old drawing
-*THEN, if drawing contain attached IMAGE FILE (.tiff in my case)
-Rename image file and repath image file based on the new file name
I have gotten it to do all of this, except I can not figure out how to change the "reference name" of the attached image file (.tiff)
Is this read-only data? I can manualy change it under xref manager, so there should be a way to do it via code...
The closest I have gotten:
;;after renaming and repath image file...
(SETQ NAME2 (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4))) (setq item (vlax-ename->vla-object (entlast)));convert to vl object (setq check (vlax-property-available-p item "Name" T));check if the entity can be updated ;if it can (if check ;change value to match (vlax-put-property item 'Name NAME2))
'Name seems to be valid w/ xref'd blocks but not xref'd/attached image files..
how to do this programmatically and without modifying the handle of the object,i am trying to do it programmatically (entmod (cons 410 newname)(assoc 410 ... no luck.
(entmakex -ing will modify or create a new handle ctrl-X and then ctrl-V recreates a new handle too ...
I want to know the correct way to find the offset origin of a layout in an AutoCAD drawing. Let say I have a drawing that has many items on it. And I create a layout showing just the items in the lower right corner of the drawing. I want to know the offset origin of this layout relative to the Model space.
I came across some LISP commands that are supposed to do just that:
Is it even possible to get the entity name of the last block added to a layout? I need to find the entity name of the last block added to each of three layouts.
Previously I was using entlast but obviously that will not descriminate per layout.
I need to get the layout list in reverse order. How to do this? My plotter outputs prints face up and I wind up with a stack of drawings in reverse order - If I can cycle through the tabs in reverse order they will wind up in the correct order in the print room!
I need to select all the viewports in the drawing and to make some changes with them, I'm planning to select them all with ssget command. If I do that I will have one viewport for the paperspace itself in every layout. One of my question is, how to know which viewport is the paperspace itself?
Second question is, how to get the name of layout in which one is the viewport? It is important to me that the lisp is really fast, so I'm planning to do the most of stuffs with vla commands.
I’m trying to create a view port, which covers my entire layout (white/ page area) using the following command
(command “mview” ‘(0 0 0) ‘(297.5 210 0))
However as you will note 0,0,0 is not the very edge corner of my layout (white area) and my white area is smaller then 297.5x 210mm (standard A4 landscape size)
How to obtain the exact measurements and starting coordinates to fully fill my entire layout page (white area)?
I need a routine that will duplicate the current sheet's Layout tab and content to the next tab, set it current, delete the titleblock (by name) on the new tab and reference in a differently named titleblock, 1:1, 0,0 onto the new Layout tab. I'll be running this in a batch script.
We have a new title block which now contains various fields to automatically populate the drawing number, number of sheets, issue etc. The problem we have is when we go to zoom all or extents on a layout tab it moves the layout to the right each time. If we only have one layout or we use a plain title block i.e. with no fields, the zoom works fine (layout stays put in the center). This is also true if we directly insert a field onto the layout - again no problems.
The cause of the problem only happens when a block containing a field is inserted onto the paper space of a layout and,there are multiple layouts containing blocks with fields.
Any LISP routine that can create multiple paper space layout tabs and can name them incrementally. I have a template and I wanted to copy tab2 of my layout multiple times and name them incrementally. I have a code shown below that comes close to what I need it to do but it creates a "New Layout" instead of copying the tab I need it to. Please see code below:
(vl-load-com)(defun c:LAYOUT+ (/ *error* prefix i n acDoc oLayouts layoutName) (defun *error* (msg) (if acDoc (vla-endundomark acDoc) ) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat " ** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) (if (and (setq prefix (getstring " Enter layout name prefix: "))
(layoutlist) ... returns a list of strings of the layout tabs in the drawing.I've used this ages... Isn't it a core lisp function, or is it coming from express tools or somewhere else?