Jump to content

Recommended Posts

Posted (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 by aridzv
  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • Beni88

    9

  • BIGAL

    7

  • rlx

    2

  • aridzv

    2

Top Posters In This Topic

Posted (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 by BIGAL

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