Jump to content

Update Attribute Title block


andy_gs

Recommended Posts

Hello Friends,

 

I have simple lisp which calucalates weight of the part . I want that weight to update automatically in the title block in WEIGHT promt, and also i want the file name to update in CAT# promt (need to remove prefix "rem", just the nummber)

 

I have attached template and aslo lisp whcih calucaltes the weight.

 

;;;To calucalate area & weight

(defun c:WT()

(COMMAND "OSNAP" "")

(setq g1(getpoint "pick the point inside the boundry of the Plate :.."))

(setq a(getreal "\nEnter the plate Thickness: "))

(command "-boundary" g1 "")

(command "area" "o" "l" )

(command "erase" "l" "")

(setq g2(getvar "area"))

(setq aa " AREA : ")

(setq g3(rtos g2))

(setq tt(* g2 0.2836 a))

(setq g4(rtos TT))

(setq NN "

")

(setq cc "WEIGHT : ")

(setq KK " Pounds.")

(setq bb(strcat aa g3 NN NN CC G4 KK))

;(alert bb)

(setq b1(strcat aa g3 NN CC G4 KK))

;(textscr)

)

 

Thannks in Advance

Andy

rem4545.dwg

Link to comment
Share on other sites

Try this code then let me know what to add or change in this one

(defun C:uptitle (/  acsp adoc  area attvalue blken blkent blkobj dens elist plate plen plent plist thk weight)
 ; fixo () 2012
 (vl-load-com)
 (setq adoc (vla-get-activedocument
             (vlax-get-acad-object))
      acsp (vla-get-block
      (vla-get-activelayout adoc)))
(vla-startundomark adoc)
(while (not
   (and (setq plen (entsel "\nSelect Plate: "))
 (eq "LWPOLYLINE"
     (cdr (assoc 0 (setq plist (entget (setq plent (car plen)))))))))
   (alert "Must be a type of Curve!"))
 (setq thk(getreal "\nEnter the plate Thickness: "))
 (setq dens(getreal "\nEnter the Density: "))
 (setq plate (vlax-ename->vla-object plent))
 (setq area (vla-get-area plate))
 (setq weight (* dens area thk))
 (setq attvalue (rtos weight 2 0))
 (while (not
   (and (setq blken (entsel "\nSelect block: "))
 (eq "INSERT"
     (cdr (assoc 0 (setq elist (entget (setq blkent (car blken)))))))))
   (alert "Must be a type of BlockReference!"))
 (vl-cmdf "_.zoom" "_o" blkent "")
 (setq blkobj(vlax-ename->vla-object blkent))  
 (if (eq (strcase (vla-get-effectivename blkobj)) "TITLE")
                       (foreach at (vlax-invoke blkobj 'getattributes)
                             (if (eq (strcase (vla-get-tagstring at)) "WEIGHT")
                                   (vla-put-textstring at attvalue)
                                   )
                             )
                       )
 (vla-endundomark adoc)
 (princ)
   )
(princ "\n\t\t---\tStart with command UPTITLE... \t---")
(prin1)
(or (vl-load-com)
(princ))

Link to comment
Share on other sites

Thank you very much for your time and it works well. If you can modify few things it will be even easier to use.

1. I want the block to select auto instead of user pick. There will be only one Attribute block in the drawing all the time.

2. Density is constant all the time. so use 0.2836 as a default

3. The plate shape may be irregular some times and may not be poly line. It’s better to use the way I calculated the area using boundary command.

4. Finally i want the drawing file name to be updated at cat # prompt. (the file name is always starts with "REM" followed by numbers. I need only numbers)

Thanks again for your help

Andy

Link to comment
Share on other sites

Thank you very much for your time and it works well. If you can modify few things it will be even easier to use.

1. I want the block to select auto instead of user pick. There will be only one Attribute block in the drawing all the time.

2. Density is constant all the time. so use 0.2836 as a default

3. The plate shape may be irregular some times and may not be poly line. It’s better to use the way I calculated the area using boundary command.

4. Finally i want the drawing file name to be updated at cat # prompt. (the file name is always starts with "REM" followed by numbers. I need only numbers)

 

Thanks again for your help

 

Andy

Link to comment
Share on other sites

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