fcfcadd Posted May 18, 2010 Posted May 18, 2010 I'm trying to figure out how to get this routine to loop. I want to be able to insert the attributal block then when all attributes have been filled it loops back to the beginning. (DEFUN C:bom () (SETVAR "attdia" 0) (SETVAR "cmddia" 0) (setq a (getpoint " Insertion Point: ")) (COMMAND "_insert" "bom.dwg" a "" "" "") (PRINC) ) Quote
alanjt Posted May 18, 2010 Posted May 18, 2010 (DEFUN C:bom (/ a) (SETVAR "attdia" 0) (SETVAR "cmddia" 0) (while (setq a (getpoint "\nInsertion Point: ")) (COMMAND "_.insert" "bom.dwg" "_non" a "" "" "") ) (PRINC) ) Quote
fcfcadd Posted May 18, 2010 Author Posted May 18, 2010 That just kept looping the insertion point and would insert the block without asking for the attributes Quote
alanjt Posted May 18, 2010 Posted May 18, 2010 Ahh, I didn't realize it was an attributed block. YOu might have to go about it a different route. Give this a try... (DEFUN C:bom (/ a) (SETVAR "attdia" 0) (SETVAR "cmddia" 0) (while (setq a (getpoint "\nInsertion Point: ")) (COMMAND "_.insert" "bom.dwg" "_non" a) (while (> (getvar 'cmdactive) 0) (command "")) (initdia) (command "_.attedit" "_L") ) (PRINC) ) Quote
fcfcadd Posted May 18, 2010 Author Posted May 18, 2010 That works. Thank you. I think I'm are going to tweak this a bit more to have it prompt "Yes/No" to proceed to next line or stop and if yes have it automatically insert the next block exactly 1/4" below the previous insertion point and not have it pull up the dialog box so where as all entries are command prompt base. Quote
alanjt Posted May 18, 2010 Posted May 18, 2010 You're welcome. You may want to look at the Polar function. Quote
fcfcadd Posted May 18, 2010 Author Posted May 18, 2010 Ok since I'm pretty much lost with how to use the polar function with what I'm wanting. I need help. Quote
alanjt Posted May 18, 2010 Posted May 18, 2010 (polar '(0 0 0) (* pi 1.5) 5.) The above example will return a point 5. feet south (* pi 1.5) (or 3pi/2) of the point 0,0,0. Quote
fcfcadd Posted May 18, 2010 Author Posted May 18, 2010 Is this right then? (DEFUN C:bom (/ a) (SETVAR "attdia" 0) (SETVAR "cmddia" 0) (while (setq a (getpoint "\nInsertion Point: ")) (polar '(0 0 0) (* pi 1.5) 5.) (command "LAYER" "S" "BORDER01" "") (COMMAND "_insert" "bom.dwg" a "" "" "") (while (> (getvar 'cmdactive) 0) (command "")) (initdia) (command "_.attedit" "_L") (PRINC) ) ) Quote
fcfcadd Posted May 18, 2010 Author Posted May 18, 2010 What we are trying to achieve is to be able to insert an attributal block, type in the attribute values at the command prompt, then have it prompt "Insert another line Y/N? if you answer Yes then it inserts the block again exactly 1/4" below the last pick point and be able to fill in the attributes again at the command prompt with one of the attributes being in sequential order from the previous input, if No then the lisp ends and so on. We are stumped. Quote
alanjt Posted May 19, 2010 Posted May 19, 2010 I'm more than willing to help, but you've got to give me ALL the information up front. Post me the block and tell me which attribute needs to be sequential. I put something together, but I'll need to make the sequential modification. If you can post it tonight, I'll do it before bed. I'll be pretty busy tomorrow (getting ready for 60% submittal), so I don't know when I can get to it. Quote
fcfcadd Posted May 19, 2010 Author Posted May 19, 2010 Here is the attributal block we are using. The MK tag is the tag we need sequential. Other than what I have already explained let me know if you need any other information. http://file:///N:/ACAD/STD/BOM.dwg Quote
alanjt Posted May 19, 2010 Posted May 19, 2010 Here is the attributal block we are using. The MK tag is the tag we need sequential.Other than what I have already explained let me know if you need any other information. http://file:///N:/ACAD/STD/BOM.dwg Something wrong with your link. Just upload the file. Quote
fcfcadd Posted May 19, 2010 Author Posted May 19, 2010 Let me know if this doesn't work. BOM.dwg BOM.dwg Quote
alanjt Posted May 19, 2010 Posted May 19, 2010 Had a minute to update with increment. Give this a try. (defun c:BOM (/ BlockName LayerName pt lst) ;; Continuously insert "BOM" block (required) and label attributes ;; Block will be placed on "BORDER01" layer (created if doesn't exist) ;; User also has option to place next block 1/4" below previously placed block ;; Alan J. Thomspon, 05.18.10 (vl-load-com) (setq BlockName "BOM" LayerName "BORDER01" ) (or *BOM:Inc* (setq *BOM:Inc* 1)) (if (or (findfile (strcat BlockName ".dwg")) (tblsearch "block" BlockName) (alert (strcat "Block: \"" BlockName "\" cannot be found!")) ) (progn (or (tblsearch "layer" LayerName) (vla-add (vla-get-layers (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) LayerName ) ) (initget 6) (setq *BOM:Inc* (cond ((getint (strcat "\n\"MK\" Increment <" (itoa *BOM:Inc*) ">: "))) (*BOM:Inc*) ) ) (while (and (if lst (setq pt (initget 0 "Exit") pt (cond ((getpoint "\nSpecify insertion point or [Exit] <1/4\" Below Last>: ")) ((polar (car lst) (* pi 1.5) 0.25)) ) ) (setq pt (getpoint "\nSpecify insertion point: ")) ) (not (eq pt "Exit")) ) ((lambda (block / val) (setq lst (cons pt lst)) (vl-catch-all-apply (function vla-put-layer) (list block LayerName)) (if (eq :vlax-true (vla-get-HasAttributes block)) (foreach att (vlax-invoke block 'GetAttributes) (if (eq (vla-get-TagString att) "MK") (progn (vla-put-TextString att (itoa *BOM:Inc*)) (setq *BOM:Inc* (1+ *BOM:Inc*)) ) (or (eq "" (setq val (getstring T (strcat "\nValue for attribute \"" (vla-get-TagString att) "\" <" (vla-get-TextString att) ">: " ) ) ) ) (vla-put-TextString att val) ) ) ) ) ) (vla-InsertBlock (if (or (eq acmodelspace (vla-get-activespace (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (eq :vlax-true (vla-get-mspace *AcadDoc*)) ) (vla-get-modelspace *AcadDoc*) (vla-get-paperspace *AcadDoc*) ) (vlax-3d-point (trans pt 1 0)) (if (tblsearch "block" BlockName) BlockName (findfile (strcat BlockName ".dwg")) ) 1. 1. 1. 0. ) ) ) ) ) (princ) ) Quote
fcfcadd Posted May 19, 2010 Author Posted May 19, 2010 Got this Command: bom Make Number Increment : Specify insertion point: _endp of OOPS: Automation Error. Filer error I am working in Autocad 2005 Quote
alanjt Posted May 19, 2010 Posted May 19, 2010 Works fine on my end. Can you send me an example drawing? Quote
fcfcadd Posted May 19, 2010 Author Posted May 19, 2010 Here is the template file we start with. The block goes in the upper right corner of the sheet in paper space. Drawing3.dwg Drawing3.dwg Quote
alanjt Posted May 19, 2010 Posted May 19, 2010 OK, I didn't test it if the block wasn't in the drawing. Try it now (updated above). 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.