Tomislav Posted February 29, 2016 Posted February 29, 2016 Hello friends.. I have a problem with getting some properties out of block...I'm trying like in these two ways (setq blok(car(entsel "\nSelect block..."))) (setq blok_vla(vlax-ename->vla-object blok)) ;1 (setq item_num (vlax-get-property blok_vla 'Count)) ... ;2 (setq item_num (vla-get-Count blok_vla)) but I always get 'ActiveX Server returned the error: unknown name:' any suggestions on how to obtain block properties Quote
Tharwat Posted February 29, 2016 Posted February 29, 2016 Hi, What are you trying to achieve ? There is not property Count with Block references. Dump the block with vlax-dump-object to see all properties & methods that is available? Quote
ksperopoulos Posted February 29, 2016 Posted February 29, 2016 If you are wanting to count the number of blocks in the drawing file, I don't think you access it via the count method. If I'm not mistaken, that just counts how many items are inside an instance of the block. Quote
marko_ribar Posted February 29, 2016 Posted February 29, 2016 (edited) You can't achieve counting through reference entity (VLA-OBJECT)... Instead use count method on definition entity (VLA-OBJECT)... To get the definition try : (setq vla-blok (vlax-ename->vla-object (tblobjname "BLOCK" (vla-get-effectivename (vlax-ename->vla-object (car (entsel "\nPick block reference..."))))))) Then try count method... [EDIT : I was wrong, you should check block definition collection VLA-OBJECT...] (vla-get-count (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename (vlax-ename->vla-object (car (entsel "\nPick block reference...")))))) Edited February 29, 2016 by marko_ribar Quote
BIGAL Posted March 1, 2016 Posted March 1, 2016 This may be what you want (setq doc (vla-get-activedocument (vlax-get-acad-object))) ; open database (setq x 0) (vlax-for block (vla-get-blocks doc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for*ent block (setq x (+ x 1)) ) ;_ end of vlax-for ) ;_ end of if (princ (strcat "\nThere are " (rtos x 2 0) "objects in block " (vla-get-name block))) ) ; end of vlax-for Quote
Tomislav Posted March 1, 2016 Author Posted March 1, 2016 Thank you all for answers...what i'm trying to do is a routine to partially explode block...it must have happened to you sometimes that you wanted to take some line or text out of block but to leave everything else in block, so i got an idea to make it in a way that you select block,than with 'nantsel' you select parts of block that you want to explode, and than with some kind of iterating function (that's why i need number of item's in block) i would get all objects from the block,remove those i want to explode and make same block without them...seems easy or? What Marko wrote gives me number of items in a block, so i will go from there...and just to say that i would probably never figure out to compose that line of code , i still don't get it exactly If you have some ideas on this lisp i'm making, or there already is that kind of lisp, i'll be happy to hear your suggestions... Quote
Lee Mac Posted March 1, 2016 Posted March 1, 2016 What i'm trying to do is a routine to partially explode block...select block, than with 'nentsel' you select parts of block that you want to explode, and than with some kind of iterating function i would get all objects from the block, remove those i want to explode and make same block without them... In very simple terms: (defun c:test ( / ent sel ) (if (and (cdddr (setq sel (nentselp))) (setq ent (entmakex (entget (car sel)))) ) (progn (vla-transformby (vlax-ename->vla-object ent) (vlax-tmatrix (caddr sel))) (vla-delete (vlax-ename->vla-object (car sel))) (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acallviewports) ) ) (princ) ) (vl-load-com) (princ) You may also find this program useful for your task. 1 Quote
Tomislav Posted March 1, 2016 Author Posted March 1, 2016 well Lee, you make it look so easy and that code is the solution....THANX now i will take some time to process this code to better understand the mechanics of it...never used matrix before... the other lisp you submitted via link is also a good example to learn from ... Quote
rlx Posted March 1, 2016 Posted March 1, 2016 In very simple terms: (defun c:test ( / ent sel ) (if (and (cdddr (setq sel (nentselp))) (setq ent (entmakex (entget (car sel)))) ) (progn (vla-transformby (vlax-ename->vla-object ent) (vlax-tmatrix (caddr sel))) (vla-delete (vlax-ename->vla-object (car sel))) (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acallviewports) ) ) (princ) ) (vl-load-com) (princ) You may also find this program useful for your task. Smooth , elegant , brilliant .... art :-) 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.