Message 1 of 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Im working on a script that will change my xrefs and save it.
Im planning to run a foreach on the code and i would like to replace StringtoFind with "a b c d" stored in a list.
I would like to change a part of the text inside a attribute, a part of a xrefs name and path and then save.
Then step to the next in my list and so on.
When i run my code i get a error message like "error: bad argument type: consp "RITNINGSNR.""
Im guessing the datatype is wrong? I was searching about (vl-princ-to-string) but im not sure if this is the way to go.
I got stuck how to fix that, any suggestions?
Other ideas and thoughts about the code are warm welcome since im a beginner.
(vl-load-com) ;------------------------------------------------
;------User input here---------------------------
;------------------------------------------------ (setq a "63B");<---- Category 1 here (setq b "63F");<---- Category 2 here (setq c "64");<----Category 3 here (setq d "64CBB");<----Category 4 here
;------------------------------------------------ (setq StringtoPut(list a b c d)) (foreach StringtoPut (setq StringtoFind "61" Attnamn "RITNINGSNR.");setq (setq ss (entnext)) (while ss (setq ed (entget ss)) (if (= Attnamn (cdr (assoc 2 ed))) (entmod (subst (cons 1 (vl-string-subst StringtoPut StringtoFind (cdr (assoc 1 ed))))(assoc 1 ed)ed)) ) (setq ss (entnext ss)) ) (vlax-for MyXref (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)));<--go through all block objects (if (and (vl-string-search (strcase StringtoFind) (strcase (vla-get-name MyXref)));<---if the name contains your string (= (vla-get-isxref MyXref) :vlax-true);<---if it's an xref ) (progn (vla-put-name myxref (vl-string-subst StringtoPut;<---Change the name (substr (vla-get-name MyXref) (1+ (vl-string-search (strcase StringtoFind) (strcase (vla-get-name MyXref)))) (strlen StringtoFind));substr (vla-get-name myxref) );string subst );vla-put-name (vla-put-path myxref (vl-string-subst StringtoPut;<---Change the Path (substr (vla-get-path MyXref) (1+ (vl-string-search (strcase StringtoFind) (strcase (vla-get-path MyXref)))) (strlen StringtoFind));substr (vla-get-path myxref) );string subst );vla-put-path (vla-reload myxref) );progn );if );vlax-for (princ) ;(command "qsave") ;(command "close") (setq filnamn(vl-filename-base(getvar "dwgname"))) (setq newname(vl-string-subst StringtoPut StringtoFind filnamn)) (setq file (strcat (getvar 'dwgprefix) newname ".dwg")) (if (findfile file) (command "_.-wblock" file "Y" "*") (command "_.-wblock" file "*") ) )
Solved! Go to Solution.