gstorrie Posted May 10, 2010 Posted May 10, 2010 Hello all I am new to autocad, We have an old lisp(98) which inserts our title block and scales it up so it fits 1:1 dwg, then we have to select from 14 dimscale size's for each style we use that match the titleblock scale, and I was wondering if thier is a lisp or vba macro that will set the dimscale to the block scale? we have no lisp or vba programers at our company an we would like to clean this up so we have only size per style. Glen Storrie Quote
alanjt Posted May 10, 2010 Posted May 10, 2010 Quickie (untested)... (defun c:Test (/ ent) (if (setq ent (car (entsel "\nSelect block to set DimScale: "))) (if (eq "INSERT" (cdr (assoc 0 (setq ent (entget ent))))) (alert (strcat "Dimscale set to: " (rtos (setvar 'dimscale (cdr (assoc 41 ent)))))) (alert "Invalid object!") ) ) (princ) ) Quote
gilsoto13 Posted May 11, 2010 Posted May 11, 2010 Hello all I am new to autocad, We have an old lisp(98) which inserts our title block and scales it up so it fits 1:1 dwg, then we have to select from 14 dimscale size's for each style we use that match the titleblock scale, and I was wondering if thier is a lisp or vba macro that will set the dimscale to the block scale? we have no lisp or vba programers at our company an we would like to clean this up so we have only size per style. Glen Storrie Check this one out by Lee, also.. http://www.cadtutor.net/forum/showthread.php?t=44989&page=2 Quote
gstorrie Posted May 12, 2010 Author Posted May 12, 2010 Thanks for those two idea's they both work and are almost just what we need, I hope i can adjust the code so that the block selection is automatic, our titleblock name never changes so Im hopping to change it from a user selection to make it hard code, once that is done the only thing i can see is if the dwg does not have a titleblock already then have the dimscale default to 1, so when it is looking for a titleblock it does not come up with an error Thanks for the help Glen Storrie Quote
alanjt Posted May 12, 2010 Posted May 12, 2010 YOu didn't give the name of your titleblock, so just replace the part in red with the name (untested)... (defun c:TEst (/ ss) ((lambda (BlockName) (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BlockName)))) (alert (strcat "Dimscale set to: " (rtos (setvar 'dimscale (cdr (assoc 41 (entget (ssname ss 0)))))) ) ) (alert (strcat BlockName " not found!")) ) ) "[color=Red]BLockName[/color]" ) (princ) ) Quote
MSasu Posted May 12, 2010 Posted May 12, 2010 May use the below code to search for title block by his name, presuming that the drawing contains one instance of that block: (and (setq TitleBlockItem (ssget "_X" (list '(0 . "INSERT") (cons '2 MyTitleBlock)))) (setq TitleBlockItem (ssname TitleBlockItem 0))) Regards, Quote
gstorrie Posted May 13, 2010 Author Posted May 13, 2010 Thanks again to those who replyied, with a bit of work I have what i was looking for, here is the code that finds the x scale factor of out titleblock and sets the dimscale to it. All the best Glen (defun c:TitleDim (/ Ent) ;; SET THE BLOCK NAME (Setq TITLE_SCALE "AMW_TITLE") ;; SEARCH ALL ENTITIES ON THE DRAWING (Setq Ent (Entnext)) (While Ent ;; IF BLOCK NAME IS FOUND EXTRACT THE SCALE OF THE BLOCK AND SET THE DIMSCALE (If (= TITLE_SCALE (cdr (Assoc 2 (Entget Ent)))) (If (= "INSERT" (cdr (Assoc 0 (Entget Ent))))(progn (rtos (setvar 'dimscale (cdr (assoc 41 (Entget Ent))))) (princ)) ) ) (Setq Ent (Entnext Ent)) ) ;; DISPLAY THE DIMSCALE OF THE DRAWING (princ (strcat "\nDimscale set to: " (rtos (getvar 'DIMSCALE)) " ")) (princ) ) Quote
alanjt Posted May 13, 2010 Posted May 13, 2010 Why'd you go with stepping through the entire drawing? (defun c:TitleDim (/ ss) ((lambda (BlockName) (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BlockName)))) (princ (strcat "\nDimscale set to: " (rtos (setvar 'dimscale (cdr (assoc 41 (entget (ssname ss 0)))))) ) ) (princ (strcat "\n" BlockName " not found!")) ) ) "AMW_TITLE" ) (princ) ) Quote
gstorrie Posted May 13, 2010 Author Posted May 13, 2010 Hi alanjt I cant answer that, the associate im my other office that i had help me set it up. All i know is that it works, Glen Quote
alanjt Posted May 13, 2010 Posted May 13, 2010 Hi alanjt I cant answer that, the associate im my other office that i had help me set it up. All i know is that it works, Glen It steps through every object in the entire drawing. It's just a very 'around-your-ass-to-your-elbow' method. 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.