aridzv Posted January 27, 2022 Posted January 27, 2022 (edited) 12 hours ago, BIGAL said: There is a has-property check so it sounds like its getting a block with no attributes. (if (= (vla-get-hasattributes blk) :vlax-true) (foreach att (vlax-invoke blk 'getattributes) ..... Hi Al and thanks for the reply. I used your code (see below),but still getting this error: ; error : bad argument type <"1In BSPT THREAD PP BLUE FILTER SCREEN 130 MICRON CHEMICALS RESISTENT_TOP-VIEW"> ; expected VLA-OBJECT at [vla-get-hasattributes] The Code I'm using: (foreach blk blks (setq obj2 (vlax-ename->vla-object (blk))) ;; set the pipe object to a VLAX object for the attribute function (Vlax-for obj (setq def (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blk))) (setq count 0) ( if (= (vla-get-hasattributes obj2) :vlax-true) (foreach att (vlax-invoke obj2 'getattributes) (if ( = tagname (strcase (vla-get-tagstring att))) (setq count (1+ count)) );;close if );;close foreach );;close if ( if (= count 0) (progn (setq AttObj (vla-addattribute def 36 acAttributeModeInvisible "" (vlax-3D-point 72 84) "SYSTEM" "" ) ;;close vla-addattribute ) ;;close setq (vlax-put AttObj 'Alignment acAlignmentmiddle) (command "_.attsync" "_N" blk) ) ;;close progon );;close if );; close foreach What I'm doing wrong? Thanks, Ari. *EDIT: when Im using (setq obj2 (vlax-ename->vla-object (entlast))) instead of (setq obj2 (vlax-ename->vla-object (blk))) it is working. is there a way to pass an object and not the last entity (entlast)? Edited January 27, 2022 by aridzv Quote
BIGAL Posted January 28, 2022 Posted January 28, 2022 (edited) Your not converting the blk to a VL object. I am not sure why you dont do something like this if code on 1st page is used. (setq ss (ssget '((0 . "INSERT")))) (if (/= ss nil) (progn (repeat (setq i (sslength ss)) (setq blk (vlax-ename->vla-object (ssname ss (setq i (- i 1))))) (if (= (vla-get-hasattributes blk) :vlax-true) (foreach att (vlax-invoke blk 'getattributes) ............... ) ; progn ) ; if Edited January 28, 2022 by BIGAL 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.