Jump to content

Arguement and sub-routine


CadFrank

Recommended Posts

Now I have this code and It's not working.

 

(defun _Modification (/ obj atts x lt Nombloc)

(initget 1 "P T D V") 
(setq Mod (getkword "\n Quel élément voulez vous modifier? [Projet/Titre/Date/Verificateur] : "))

 (if (= Mod "P")
     (progn
 (setq TProjet (strcase (getstring T "\n Quel est le nouveau nom du projet? ")))
 (setq TagPro "PROJET")
 (_getall->Layout (if (= Tag (vla-get-tagstring x))
               (vla-put-textstring x Text)
    )
 )
     )
 )

 

(defun _getall->Layout (Tag Text / adoc nombloc)

(setq Nombloc '("LU CARTOUCHE"		  "Cartouche Aliance"
	"LC CARTOUCHE CHUM"	  "LC CARTOUCHE CHUM 2"
	"LC CARTOUCHE"		  "LU CARTOUCHE PANNEAU"
	"CARTOUCHE LU"		  "LC CARTOUCHE 2"
       )
)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))

 (vlax-for lt (vla-get-layouts adoc)
   (vlax-for obj (vla-get-block lt)
     (if (and (= "AcDbBlockReference" (vla-get-objectname obj))
       (member (vla-get-effectivename obj) Nombloc)
       (= :vlax-true (vla-get-hasattributes obj))
  )
(progn
  (setq atts (vlax-invoke obj 'getattributes))
  (foreach x atts
    (if	(= Tag (vla-get-tagstring x))
      (vla-put-textstring x Text)
    )
  )
)
     )
   )
 )
)

 

it send's me the error

 

; error: bad argument type: VLA-OBJECT nil

 

And i don't understand why.. since obj is the vla-object.

Link to comment
Share on other sites

VLA-OBJECT - layouts don't have VLA-OBJECT - block as subobject...

 

Try to change last paragraph to this :

 

(vlax-for obj (vla-get-blocks adoc)
 (if (and (= "AcDbBlockReference" (vla-get-objectname obj))
            (member (vla-get-effectivename obj) Nombloc)
            (= :vlax-true (vla-get-hasattributes obj))
     )
   (progn       
     (setq atts (vlax-invoke obj 'getattributes))
     (foreach x atts         
       (if    (= Tag (vla-get-tagstring x))
         (vla-put-textstring x Text)
       )
     )
   )
 )
) 

HTH

 

[EDIT] : Just checked - you probably thought on VLA-OBJECT - ActiveLayout, so... :

(vlax-for lt (vla-get-[color=red]activelayout[/color] adoc)
 (vlax-for obj (vla-get-block lt)
   (if (and (= "AcDbBlockReference" (vla-get-objectname obj))
              (member (vla-get-effectivename obj) Nombloc)
              (= :vlax-true (vla-get-hasattributes obj))
       )
     (progn       
       (setq atts (vlax-invoke obj 'getattributes))
       (foreach x atts         
         (if    (= Tag (vla-get-tagstring x))
           (vla-put-textstring x Text)
         )
       )
     )
   )
 )
)

Edited by marko_ribar
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...