Jump to content

Trouble with ssget on blocks inserted from a Tool Palette


Inferno

Recommended Posts

I've been using this lisp to fill in the attribute on agroup of blocks. We recently loaded all of our standard blocks onto a toolpalette. The problem I’m having is that the ssget seams to ignore the block ifit was inserted from the tool palette. IfI insert the block via Insert/Block, the lisp will add the text correctly. If I drag a functioning block onto the toolpalette and reinsert it into the same drawing the ssget ignores it.

The only way I can make it work is to remove the block namefilter, but I can’t explain why that would make a difference. I tried adding a wild card to the bock nameand the ssget still ignores its.

Any help would be appreciated.

(defun C:ELVMKNB ( / );PT1 PT2 Mrknbr ss i sn n e )

;;; Tharwat 27. march. 2012 ;;;

;;; Jeff E June 2014 ;;;

(while

(SETQ PT1 (GETPOINT "\nSelect the LOWER LEFT corner of the Elevation: "))

(SETQ PT2 (GETCORNER PT1 "\nSelect the UPPER RIGHT corner of the Elevation: "))

(setq Mrknbr (getstring "\nEnter Elevation Number and Page Number (XX/X.XX): "))

(command "_zoom" "W" pt1 pt2)

 

(if (setq ss (ssget "W" PT1 PT2 '((0 . "INSERT")(2 . "MRKNUM2")(66 . 1))))

(repeat (setq i (sslength ss))

(setq sn (ssname ss (setq i (1- i))))

(setq n (entnext sn))

(while

(not

(eq (cdr (assoc 0 (setq e (entget n))))

"SEQEND"

)

)

;(setq Mkr (strcat (cdr (assoc 1 e)) Mrknbr))

(if (eq (strcase (cdr (assoc 2 e))) "ELEV#")

(entmod (subst (cons 1 Mrknbr ) (assoc 1 e) e))

)

(setq n (entnext n))

)

)

)

;end repeat

(princ)

(command "_zoom" "p")

(princ "BLOCKES CHANGED:")(PRINC (sslength ss)) (PRINC " SELECT NEXT ELEVATION")

 

)

(princ)

)

 

Link to comment
Share on other sites

(entmod (subst (cons 1 Mrknbr ) (assoc 1 e) e))

 

I'm not entirely sure what your code does, but are you sure the object has a dotted pair for code 1? My script to change attribute colors was failing because I was trying to (subst) (cons 62 color) for (assoc 62 blockname). As it turns out, such a dotted pair does not exist unless the attribute color was changed previously. Freshly inserted blocks didn't have a dotted pair indicating color; it would assume the colors stated in the block definition until stated otherwise. Maybe you're having the same problem. Do an (entget e) to check if there is an entry for (1 . something). If the entry doesn't exist, use (append) instead of (subst)

Link to comment
Share on other sites

You shouldn't do the ssget with dynamic block name, only (ssget '((0 . "INSERT") (66 . 1)) , because dynamic block can easily change to anonymous block with name like "*U..." , and you can't get them. Instead you use function vla-get-EffectiveName to choose the exact blocks.

Link to comment
Share on other sites

You shouldn't do the ssget with dynamic block name, only (ssget '((0 . "INSERT") (66 . 1)) , because dynamic block can easily change to anonymous block with name like "*U..." , and you can't get them. Instead you use function vla-get-EffectiveName to choose the exact blocks.

 

Very interesting. That would explain why a different script of mine couldn't change the text or mtext color in dynamic blocks. It was trying to -bedit the block based on ssget, but it would end up opening block editor with no block. I'll keep this in mind next time.

Link to comment
Share on other sites

You shouldn't do the ssget with dynamic block name, only (ssget '((0 . "INSERT") (66 . 1)) , because dynamic block can easily change to anonymous block with name like "*U..." , and you can't get them. Instead you use function vla-get-EffectiveName to choose the exact blocks.

 

Thanks 7o7.

You are correct about Autocad changing a dynamic block name to an anonymousblock. Looks like I will need to find awork around.

Link to comment
Share on other sites

  • 2 years later...

I found this thread because I was trying to use ssget to group objects so that I could set visibility states. I have gotten away with it previously but the one a ran into problems with has 15 visibilty states (if I can get it to work). So......what do you commonly do to group objects so that you can define visibility???? I am trying to create fifteen vis states with a couple of flips, a couple rotates, a property table for five attributes and a couple attributes with values defined by user input. Each of the seven attributes get written out to excel. I'm following a flow diagram but any way of making the vis states a little less cumbersome would be great for this as well as future definitions.

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