Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/28/2022 in all areas

  1. Thanks for the help! Also special thanks for allowing me to pick the row for the special pieces. This is so neat
    1 point
  2. Don't know if you have multiple graphs so this will ask you to pick the "Row" to get the Y cords. x cords are pulled form the text. then its just a simple move command. will display an error message if either multiple text are found or no text are found. ;;----------------------------------------------------------------------------;; ;; Move Blocks to graph location (defun C:BlkMove (/ x y ss txt blk atts oTag) (setq y (cadr (getpoint "\nPick \"SPECIAL PIECES\" Row"))) (prompt "\nSelect Blocks") (setvar 'cmdecho 0) (if (setq ss (ssget '((0 . "INSERT") (2 . "AHS-1T,AHS-1TR,AHS-2T,AHS-2TR") (66 . 1) (410 . "Model")))) (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq PT (cdr (assoc 10 (entget blk)))) (setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes (vlax-ename->vla-object blk))))) (foreach tag atts (if (eq (vla-get-tagstring tag) "TEE") (progn (setq oTag (vla-get-textstring tag)) (if (setq txt (ssget "_X" (list '(0 . "*TEXT") (cons 1 oTag) '(410 . "Model")))) (if (eq (sslength txt) 1) (progn (setq x (car (cdr (assoc 10 (entget (ssname txt 0)))))) (vl-cmdf "_.Move" blk "" "_non" PT "_non" (list x y)) ) (prompt (strcat "\nMultiple Text Found [" oTag "]")) ) (prompt (strcat "\nText not Found [" oTag "]")) ) ) ) ) ) ) (setvar 'cmdecho 1) (princ) )
    1 point
  3. Okay, this should get you started: (defun c:FOO (/ ss) (vl-load-com) (if (setq ss (ssget "_x" '((0 . "INSERT") (2 . "WD_METR") (66 . 1)))) ((lambda (i / e s od r v n d tag) (while (setq e (ssname ss (setq i (1+ i)))) ;; Extract object data (setq b (ade_odgetfield e (setq od (car (ade_odgettables e))) "BARCODE" 0)) (setq s (strcase (ade_odgetfield e od "STATUS" 0))) ;; Populate attributes (if (and (setq n (vla-get-effectivename (setq v (vlax-ename->vla-object e)))) (setq d (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) n))) (foreach attrib (vlax-invoke v 'getattributes) (vlax-for item d (if (= (vla-get-objectname item) "AcDbAttributeDefinition") (if (= (vla-get-tagstring attrib) (vla-get-tagstring item)) (cond ((= "BARCODE" (setq tag (vla-get-tagstring item))) (vla-put-textstring attrib b)) ((= "STATUS" tag) (cond ((= "MANUAL" s) (vla-put-textstring attrib "M")) ((= "RADIO" s) (vla-put-textstring attrib "X")) ((vla-put-textstring attrib "?")))))))))) [color=seagreen];; Write data to excel[/color] )) -1)) (princ)) I revised your block a bit (hope you don't mind), so that instead of using Text at the center of the block, you now have an Attribute, which changes between "M" (Manual), "X" (Radio), and "?" (Others). I used the "Status" field for populating this attribute. Next, I'm working on a segment of code which will insert the new block at the old block's location, and add the Object Data from the old to the new, then delete the old block. This should only be required to be run once per drawing. Please start the "write to excel" part, so we can combine them. WD_METR.dwg
    1 point
×
×
  • Create New...