PDA

View Full Version : How can I purge a block definition without using purge command ?



kennet.sjoberg
2006-08-10, 10:34 AM
Like this, but i does not work


(setq EntName (tblobjname "BLOCK" "MyTemporaryBlock" ) )
(entdel EntName )



: ) Happy Computing !

kennet

T.Willey
2006-08-10, 03:42 PM
Maybe make sure that there is no inserts of the block name, and then try to delete it from the block collection. It maybe nested though.



(defun DeleteBlockDef (BlkName)

(if (ssget "x" (list (cons 2 BlkName)))
(prompt "\n There are still inserts of this block.")
(if
(vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ()
(vla-Delete
(vla-Item
(vla-get-Blocks
(vla-get-ActiveDocument
(vlax-get-Acad-Object)
)
)
BlkName
)
)
)
)
)
(prompt "\n Block definition could not be deleted.")
(prompt "\n Block definition was deleted.")
)
)
(princ)
)

kennet.sjoberg
2006-08-10, 04:59 PM
No, there is no inserts or nested block, just a blockdefinition, so the . . .


(vla-Delete (vla-Item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object )) ) BlkName ))

. . .did the trick.

Thank you very much Tim and

: ) Happy Computing !

kennet

kennet.sjoberg
2006-08-10, 07:46 PM
BTW
I have problem with the (vla-get-WhatCanISelectHere
for example UCS or equals, is there any information in the help document to find it ?

: ) Happy Computing !

kennet

intergrupocr
2006-08-10, 08:01 PM
It depends of the object, you can try to dump the object to see all the properties that you can (vla-get)


(vlax-dump-object object T)

T.Willey
2006-08-10, 08:55 PM
You're welcome Kennet. As intergrupocr mentioned, you can do that per object you have. You can look through the help files also, that is where I learned most of the ActiveX controls. Once you're in the help files, get to the Developers Guide. Then you will want to look at the ActiveX and VBA Reference. In there you will have a couple other book type things to select from. If you select the object one, then you will get a list of all the objects, and then when you select on one of them, it will go specific to that one object, and it will show all the properties/methods/events for that object. The only problem is getting the right syntax in lisp. One example is
(vlax-invoke BlkObj 'GetAttributes)
Will return a list of all the blocks attributes as objects
(vla-GetAttributres BlkObj)
Will return a variant of all the blocks attributes as objects. These come with experience.

kennet.sjoberg
2006-08-16, 07:55 AM
You're welcome Kennet. . .
Tank you Tim and intergrupocr, this is still a jungle for me and I have to play a lot more to have the experience.

: ) Happy Computing !

kennet