jmerch Posted January 27, 2012 Posted January 27, 2012 I have a LISP that needs to insert a table onto a sheet but the table placement is dependent on the sheet size. The only way I can think of (I'm sure there's 10 more) to recognize the sheet is by getting the LIMMAX variable. From there the insertion point will be in a COND statement (if the sheet size is this, insert here, etc.) The only problem is I can't use the numbers after I've stored them. How do I get them to change to either an integer or string? I'm not sure what they are considered. atoi and itoa don't do it. Thanks. Quote
elfert Posted January 27, 2012 Posted January 27, 2012 (edited) Do you have a drawing head in the drawing ? I have had a similar issue that i fixed with this lisp see below: http://www.cadtutor.net/forum/showthread.php?65817-Finding-a-blocks-insertion-point-and-inserting-a-another-block-in-the-same-spot. ;Inserts a 'Blockname1' sign in the selected blocks insertion point.call commando with Blockinsert1, So i you have a for example a AS build sign you need over a drawing head you could make it like a block and put it in known folder of autocad. (Defun C:Blockinsert1 ( / ans en inspt) (setq ans (entsel)) (setq en (entget (car ans))) (setq inspt (cdr (assoc 10 en))) (Command "-insert" "Blockname1" inspt "" "" "" ) ) ;inserts a 'Blockname2' sign in the same spot as the blockname1 insertion point. call commando with blockinsert2. So if you want Blockname2 to be in special place from the insertion point of the blockname1 you could maybe use this routine you just need Make blockname2 insertion point the same as Blockname1. (defun c:blockinsert2 (/ a b c) (setq a (ssget "_X" '((0 . "INSERT") (2 . "Blockname1"))) b (sslength a) ) (repeat b (setq b (1- b) c (append c (cdr (assoc 10 (entget (ssname a b))))) ) ) (command "insunits" "4" "") (Command "-insert" "blockname2" c "" "" "" ) (princ) ) Maybe this could give some advice what to do! Remember the insunits is mayby not necessary in you case it just change the insertion unit to metric (Just to let you know). elfert Edited January 27, 2012 by elfert Misleading Quote
BlackBox Posted January 27, 2012 Posted January 27, 2012 The LIMMAX can be unreliable as a user can simply turn off the 'paper background' or 'printable area is displayed' settings. Typically, when a sheet is a different size, the scale of each is known (presuming you have consistent CAD standards). If using something simple like the DIMSCALE variable is potentially inconsistent, then instead consider using a selection set test for different sized title blocks, etc. Example: If your drawing has an 11x17 title block, then you insert for 11x17 location. If your drawing has a 24x36 title block, then insert for a 24x36 location. HTH Quote
jmerch Posted January 27, 2012 Author Posted January 27, 2012 @elfert - I don't have a block in the drawing to recognize. The LIMMAX can be unreliable as a user can simply turn off the 'paper background' or 'printable area is displayed' settings. Typically, when a sheet is a different size, the scale of each is known (presuming you have consistent CAD standards). If using something simple like the DIMSCALE variable is potentially inconsistent, then instead consider using a selection set test for different sized title blocks, etc. Example: If your drawing has an 11x17 title block, then you insert for 11x17 location. If your drawing has a 24x36 title block, then insert for a 24x36 location. HTH I'm not familiar with turning off the 'paper background' or 'printable area is displayed' settings...but do they really affect limits? Aren't limits a hard coded number that gives boundaries, not just for how it looks? In your example, that's exactly what I'm trying to do but don't understand what you're saying about how to recognize the sheet size. Just because the sheet size is different, doesn't necessarily mean the DIMSCALE is different, in my experience. Could you clarify please? Thanks, I appreciate the help. Quote
BIGAL Posted January 30, 2012 Posted January 30, 2012 You can set limits but then do a zoom extents and this will not match the limits, a zoom all will match limits. Limits is user definable. Quote
BlackBox Posted January 30, 2012 Posted January 30, 2012 I don't have a block in the drawing to recognize. Do you have an XREF that contains a title block that can be used to determine which sheet size you require? If so, one might employ ObjectDBX to 'extract' the needed information. Could you clarify please? On the LIMMAX system variable - LIMMAX Stores the upper-right grid limits for the current space, expressed as a world coordinate. LIMMAX is read-only when paper space is active and the paper background or printable area is displayed. Quote
jmerch Posted January 31, 2012 Author Posted January 31, 2012 Do you have an XREF that contains a title block that can be used to determine which sheet size you require? I have my border Xref, but doesn't contain a titleblock with insertion point. I have figured out how to get the point (see code snippet below)...but with this specific function, it does not work. The function is from a third party program which will place an ACAD table but no matter what I try, can't get it to automatically place it...it's still up to the user to manually do it. I'll keep playing with it though. (command "id" (getvar "limmax")) (setq pt (getvar "lastpoint")) what I've been told to do by the third party programmer, but it does not work... (command (addreport "Sleeve Report" (ssget "all") (list pt))) Quote
BlackBox Posted January 31, 2012 Posted January 31, 2012 If your 'border' is not an actual title block, and is XREF-ed, then can you not calculate the POLAR point location via the origin '(0 0 0)? Otherwise, you need to extract the sheet size from a discernible file name for the XREF. IMO, you would do well to create some appropriately named title blocks... Sure would make this a whole lot simpler. Quote
jmerch Posted January 31, 2012 Author Posted January 31, 2012 How do you mean "calculate the POLAR" point? I don't have appropriately named title blocks due to our border is always named the same thing (Brd) in the job folder and the titleblock information is filled out on the actual layout tab in the model (other than the job name, information, etc). I have it setup a little different b/c of this third party program in terms of I don't just have an attributed block called Title Info or something like that. I appreciate your input (as I always learn) and while there is 100 ways to accomplish the same task, I think the "id" way is sufficient and simple enough (until I understand the POLAR calc ) but as I said, useless anyways b/c I can't get it to auto-place my table anyways....but I'll keep playing with it. Quote
BlackBox Posted January 31, 2012 Posted January 31, 2012 Giving this some more thought - Consider extracting the coordinate you need from: (defun c:FOO (/ e mn mx) (vl-load-com) (if (setq e (car (entsel))) (progn (vla-getboundingbox (vlax-ename->vla-object e) 'mn 'mx) (terpri) (foreach x (list "\nBottom Left coordinate: " (vlax-safearray->list mn) "\nUpper Right coordinate: " (vlax-safearray->list mx)) (princ x)) (textscr)) (prompt "\n** Nothing selected ** ")) (princ)) Quote
BlackBox Posted January 31, 2012 Posted January 31, 2012 In terms of the polar calc, what I mean is that if your border is always XREF-ed, then it remains in the same location in every sheet (i.e., you always insert at '(0 0 0), right?) If the border remains in the same location each time, then you can list, id, or getpoint for any needed points which should remain the same every time. Make sense? God forbid you setup multiple sheets in the same tab, and just copy, copy, copy... that would be most unfortunate. Quote
jmerch Posted January 31, 2012 Author Posted January 31, 2012 Regarding your code example, isn't that the same as the "id" example I had? I understand you're saying there's a chance users can change how the limmax is affected, but I'm pretty sure my guys don't mess with any of that (but you never know...it's always the quiet ones you gotta watch ) As far as the polar calc, yes I see what you mean now, just the wording threw me off. No we don't do multiple sheets per tab, that's crazy! Quote
BlackBox Posted January 31, 2012 Posted January 31, 2012 Actually, no, the code I provided is not the same as ID, as this code provides the Bottom Left, and Upper Right coordinates for the selected entity. Were you to select the XREF-ed border, then you'd have something similar to an insertion point for said block (were it an actual title block). In any event, this method also does not modify any system variables, as the coordinates being extracted originate from the selected entity, and not the system variables. This code can be manipulated to automatically detect these coordinates (or the one of your choosing) from any "brd" XREF-ed in your layouts, which should reveal the 'size' of your sheet(s) at the appropriate time. Again, this is possible, as your XREF-ed "brd"'s will always be inserted at the same location, etc.. Make sense? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.