Jump to content

What is going wrong? (copy attributes from mspace to pspace lisp)


CADkitt

Recommended Posts

It all works fine if you do it by hand, but if I run it all at once in a script it just deletes all attributes :geek:

The stranged part is it deletes the attribute in the mspace template, and I only copy and not modify the attributes in mspace.

 

Edit: it looks like catt and patt are not working in script when activated by selection. Some one any idea why? I didn't made that lisp and I am not really familiar in visuallisp.

Edit2: Stitching catt and patt together gived the same results.

(defun c:test8(/ blks)
(command "mspace")
(sssetfirst nil (ssget "_x" '((0 . "INSERT")(2 . "Template"))))
;(c:catt)
 (cattt)
(setq blks (ssget "_x" '((0 . "INSERT")(2 . "Template"))))
(command "zoom" "o" blks "")
;(command "erase" blks "")
(command "pspace")
(sssetfirst nil (ssget "_x" '((0 . "INSERT")(2 . "Template"))))
;(c:patt)
 (pattt)
(command "zoom" "all")
 )
;I didn't make this part!!!
(defun cattt(/ sSet)
 ;(changeTags)
 (vl-load-com)
 (princ "\n<<< Select block to copy attributes >>>")
 (if
   (setq sSet(ssget "_:S" '((0 . "INSERT")(66 . 1))))
   (progn
     (setq cBl(vlax-ename->vla-object(ssname sSet 0)))
     (vl-bb-set 'atLst(cons
		 (vla-get-Name cBl)
		   (mapcar '(lambda(x)
		    (vla-get-TextString x))
		       (vlax-safearray->list
	                 (vlax-variant-value
			   (vla-GetAttributes
			     cBl))))))
     (princ "\n<<< Attribute value(s) were copied >>>")
     ); end progn
   (princ "\n>>> This isn't block with attribute(s)! <<< ")
   ); end if
 (princ)
 ); end of c:catt

(defun c:catt () (cattt))

;**** Paste attributes values to multiple blocks ****

(defun pattt(/ sDat dLst fLst blSet)
 (vl-load-com)
 (if
   (setq sDat(vl-bb-ref 'atLst))
   (progn
     (setq fLst(list '(0 . "INSERT")(cons 2(car sDat)) '(66 . 1))
    dLst(cdr sDat)
    ); end setq
     (princ(strcat "\n<<< Current block to paste is '" (car sDat) "' >>> "))
      (if
(setq blSet(ssget fLst))
  (foreach bl (mapcar 'vlax-ename->vla-object 
                      (vl-remove-if 'listp 
                        (mapcar 'cadr(ssnamex blSet))))
    (mapcar 'vla-put-TextString
	    (vlax-safearray->list
	     (vlax-variant-value
	       (vla-GetAttributes bl)))dLst)
    ); end foreach
 (princ "\n>>> Nothing selected! <<< ")
); end if
     ); end progn
   (princ "\n >>> There isn't attributes datas to paste! <<< ")
   ); end if
 (princ)
 ); end of c:patt

(defun c:patt () (pattt))

Edited by CADkitt
Link to comment
Share on other sites

How are you '[running] it all at once in a script'... Do you mean with an .SCR file?

 

Or do you simply mean that you tried running one command (i.e., c:TEST8 ), which does all steps at once?

Link to comment
Share on other sites

I just want to run it all at once with a cmd but I need to check if it went good, so using scr wouldn't work.

It's gonna be part of a bigger lisp file.

Link to comment
Share on other sites

I already updated the grammar :)

I think it is going wrong at the selection sets, maybe I should change them in catt an patt.

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