3dwannab Posted July 6, 2018 Posted July 6, 2018 Hi all, Here's a routine originally wrote by LeeMac. I wanted to delete the previously inserted blocks after it's done updating them. Thanks in advance. I'll wrote where the problem lies in my code. (defun c:BK_Update_InsertAll_Redefine_ATTSYNCAll ( / dir doc extn spc ) (setq extn "dwg") ;; Extension of files to Insert e.g "dwg" (if ; (setq dir (LM:DirectoryDialog (strcat "Select Directory of " (strcase extn) " Files to Insert") nil 512)) (setq dir "W:/SS_CAD/SS_AutoCAD Block's Library/Blocks Updated/" blk "`.dwg") (progn (setq doc (vla-get-activedocument (vlax-get-acad-object)) spc (vlax-get-property doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)) ) (foreach file (vl-directory-files dir (strcat "*." extn) 1) (vla-insertblock spc (vlax-3D-point '(0.0 -50.0 0.0)) (strcat dir "\\" file) 1.0 1.0 1.0 0.0) ) (vla-regen doc acallviewports) (command "ATTSYNC" "NAME" "*") ; NOT WORKING, I want to delete the previously inserted block. (vlax-delete (vlax-ename->vla-object spc)) ) (princ "\n*Cancel*") ) (princ) ) Quote
Tharwat Posted July 6, 2018 Posted July 6, 2018 Hi, The variable 'spc' represents the space object and not the block reference so replace the variable spc with (entlast) besides that you can use the function entdel to avoid converting the object to vla-object since its not needed later on for any use. (entdel (entlast)) Quote
3dwannab Posted July 6, 2018 Author Posted July 6, 2018 Hi, The variable 'spc' represents the space object and not the block reference so replace the variable spc with (entlast) besides that you can use the function entdel to avoid converting the object to vla-object since its not needed later on for any use. (entdel (entlast)) Thanks Tharwat, I've done what you suggested and it errors out. error: bad function: #<VLA-OBJECT IAcadPaperSpace 000001e97f6fa558> My code: (defun c:BK_Update_InsertAll_Redefine_ATTSYNCAll ( / dir doc extn entlast ) (setq extn "dwg") ;; Extension of files to Insert e.g "dwg" (if ; (setq dir (LM:DirectoryDialog (strcat "Select Directory of " (strcase extn) " Files to Insert") nil 512)) (setq dir "W:/SS_CAD/SS_AutoCAD Block's Library/_DM Arch Blocks (Company Master Blocks)/1508 Blocks Updated/" blk "`.dwg") (progn (setq doc (vla-get-activedocument (vlax-get-acad-object)) entlast (vlax-get-property doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)) ) (foreach file (vl-directory-files dir (strcat "*." extn) 1) (vla-insertblock entlast (vlax-3D-point '(0.0 -50.0 0.0)) (strcat dir "\\" file) 1.0 1.0 1.0 0.0) ) (vla-regen doc acallviewports) (command "ATTSYNC" "NAME" "*") (entdel (entlast)) ) (princ "\n*Cancel*") ) (princ) ) Quote
Tharwat Posted July 6, 2018 Posted July 6, 2018 Entlast is a function and you can not use it as variable otherwise you would have lots of error clashes so just replace it as follows: This: (vlax-delete (vlax-ename->vla-object spc)) with this: (entdel (entlast)) Quote
3dwannab Posted July 6, 2018 Author Posted July 6, 2018 Entlast is a function and you can not use it as variable otherwise you would have lots of error clashes so just replace it as follows: This: (vlax-delete (vlax-ename->vla-object spc)) with this: (entdel (entlast)) Silly me. I got carried away there. Many thanks, Tharwat! Quote
Grrr Posted July 6, 2018 Posted July 6, 2018 BTW theres no vlax-delete function, you can check in VLIDE: _$ vlax-delete nil _$ vla-delete #<SUBR @00000083291f4188 vla-Delete> So the correct call would be either (vla-delete ) or (vlax-invoke-method 'Delete). Quote
3dwannab Posted July 6, 2018 Author Posted July 6, 2018 BTW theres no vlax-delete function, you can check in VLIDE: _$ vlax-delete nil _$ vla-delete #<SUBR @00000083291f4188 vla-Delete> So the correct call would be either (vla-delete ) or (vlax-invoke-method 'Delete). Thanks. So basically what you're saying is it needs an argument in the form of a ? Quote
Grrr Posted July 6, 2018 Posted July 6, 2018 Thanks. So basically what you're saying is it needs an argument in the form of a ? Yes, I guess you want to store into a variable the return of the vla-InsertBlock method, since it returns the vla-object of the inserted block.. and then use vla-Delete method on it. Quote
Grrr Posted July 6, 2018 Posted July 6, 2018 Good catch Grrr, Thanks, Tharwat! Hope the OP learnt something here.. Quote
3dwannab Posted July 6, 2018 Author Posted July 6, 2018 Thanks, Tharwat! Hope the OP learnt something here.. Well, that could be debatable. 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.