Jump to content

Recommended Posts

Posted

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)

)

  • Replies 29
  • Created
  • Last Reply

Top Posters In This Topic

  • fcfcadd

    17

  • alanjt

    13

Top Posters In This Topic

Posted
(DEFUN C:bom (/ a)
 (SETVAR "attdia" 0)
 (SETVAR "cmddia" 0)
 (while (setq a (getpoint "\nInsertion Point: "))
   (COMMAND "_.insert" "bom.dwg" "_non" a "" "" "")
 )
 (PRINC)
)

Posted

That just kept looping the insertion point and would insert the block without asking for the attributes

Posted

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)
)

Posted

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.

Posted

You're welcome. :)

 

You may want to look at the Polar function.

Posted

Ok since I'm pretty much lost with how to use the polar function with what I'm wanting. I need help.

Posted

(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.

Posted

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)

)

)

Posted

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.

Posted

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.

Posted

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

Posted
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.

Posted

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)
)

Posted

Got this

Command: bom

 

Make Number Increment :

 

Specify insertion point: _endp of OOPS: Automation Error. Filer error

 

I am working in Autocad 2005

Posted

Works fine on my end. Can you send me an example drawing?

Posted

OK, I didn't test it if the block wasn't in the drawing. Try it now (updated above).

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...