Jump to content

Recommended Posts

Posted

Hi everyone.

 

I'm try to make a selection with a (ssget "x" '((2 "parking"))) but the block named "parking" it's a dinamic block. I have been discover that dinamic blocks behave like a AEC Object renamed his name with a alphanumeric code.

 

block1.jpg

 

Like you can see the name of the block is "parking_car", but when you make a "entsel" give this result: "((-1 . ) (0 . "INSERT") (5 . "3326") (102 . "{ACAD_XDICTIONARY") (360 . ) (102 . "}") (330 . ) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "*U72") (10 0.0 0.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))"

 

I need select all this blocks to make a list and set a incremental number inside.

 

Someone can help me?

 

Thanks

 

Juanra

Posted (edited)
  juanragal said:
Hi everyone.

 

I'm try to make a selection with a (ssget "x" '((2 "parking"))) but the block named "parking" it's a dinamic block. I have been discover that dinamic blocks behave like a AEC Object renamed his name with a alphanumeric code.

 

attachment.php?attachmentid=63959&stc=1

 

Like you can see the name of the block is "parking_car", but when you make a "entsel" give this result: "((-1 . ) (0 . "INSERT") (5 . "3326") (102 . "{ACAD_XDICTIONARY") (360 . ) (102 . "}") (330 . ) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "*U72") (10 0.0 0.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))"

 

I need select all this blocks to make a list and set a incremental number inside.

 

Someone can help me?

 

Thanks

 

Juanra

 

 

You're missing a point in your code it should read

 (ssget "x" '((2 [color=red].[/color] "parking")))

but IMHO you should be looking for blocks

 

 

 (ssget "x" '((0 . "INSERT")))

then loop through the blocks checking if the blocks effectivename property = "parking"

 

Cut and paste the following to the command line and press enter.

 

 

(vlax-dump-object (vlax-ename->vla-object (car (entsel "\nSelect Entity : "))) T)

This should give you a list of properties for the object. If it is an anonymous block (*U..) one of the properties near the top of the list will be "EffectiveName"

 

 

This is the name of the block entity on which it is based.

 

Look here for code to access this using autolisp and visual lisp =>http://www.lee-mac.com/effectivename.html

Edited by dlanorh
Posted

Hi dlanorh. thanks for your answer.

 

You are right. I missing a point in a text, but no in my code ;). I want to select all blocks with the "Effectivename" Parking-car on my draw.

 

I try to see the page that you give me, but the link are broken.

Posted (edited)

Since you want to select on screen like with using QSELECT command, this snippet would do it in active layout block space (Model Space) - it won't search nesting of blocks since you can't visually select them - you can only retrieve their enames by using (tblobjname) function in combination with (entnext) and query INSERT entities...

 

 

(defun geteffnamess ( effname / ss i bl )

 (vl-load-com)

 (setq ss (ssget "_A" (list '(0 . "INSERT") (if (= (getvar 'cvport) 1) (cons 410 (getvar 'ctab)) (cons 410 "Model")))))
 (repeat (setq i (sslength ss))
   (setq bl (ssname ss (setq i (1- i))))
   (if (vlax-property-available-p (vlax-ename->vla-object bl) 'EffectiveName)
     (if (/= (vla-get-EffectiveName (vlax-ename->vla-object bl)) effname)
       (ssdel bl ss)
     )
     (ssdel bl ss)
   )
 )
 (sssetfirst nil ss)
 (princ)
)

;; (progn (geteffnamess "PARKING_CAR") (if (cadr (ssgetfirst)) (setq ss (ssget "_:L-I"))))

(defun geteffnamess-bad ( effname / ss i bl )

 (vl-load-com)

 (setq ss (ssget "_A" (list '(0 . "INSERT") (if (= (getvar 'cvport) 1) (cons 410 (getvar 'ctab)) (cons 410 "Model")))))
 (setq i -1)
 (repeat (sslength ss)
   (setq bl (ssname ss (setq i (1+ i))))
   (if (vlax-property-available-p (vlax-ename->vla-object bl) 'EffectiveName)
     (if (/= (vla-get-EffectiveName (vlax-ename->vla-object bl)) effname)
       (ssdel bl ss)
     )
     (ssdel bl ss)
   )
 )
 (sssetfirst nil ss)
 (princ)
)

;; (progn (geteffnamess-bad "PARKING_CAR") (if (cadr (ssgetfirst)) (setq ss (ssget "_:L-I"))))

EDIT : You can easily make mistake with this snippet... Look closely for variable "i"... Why does decrement of "i" values work and increment doesn't? Hint : What does (ssdel) function do to sel. set "ss" ?

Edited by marko_ribar
added bad code for learning purposes
Posted

Hi,

 

To reduce the quantity of selecting the target block name but this still requires iteration over selected blocks.

 

(ssget  (list '(0 . "INSERT") (cons 2 (strcat "`*U*," "parking"))))

Posted

Wow! Thanks you for yours suggestions. I will try the code and say something.

You do a great job!

Rewards

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