select block and open bedit

select block and open bedit

Anonymous
Not applicable
2,510 Views
6 Replies
Message 1 of 7

select block and open bedit

Anonymous
Not applicable

I'm hoping someone can help me with this issue. I'm trying to create a lisp that will prompt the user to select a block then edit the block and change all the entities to layer 0 and bylayer.

 

Here is what i have. I've tried several different methods but i haven't had any luck so far. I'm obviously new to LISP and programming in general. 


(defun c:fb (/ block bname)
(setq block (ssget'((0 . "INSERT"))))
(setq bname (cdr (assoc 2 (entget(ssname block)))))
(command "-bedit" bname )
(command "change" "all" "" "p" "la" "0" "")
(command "setbylayer" "all" "" "yes" "yes")
(princ)
)

 

Thanks in advance. 

0 Likes
Accepted solutions (1)
2,511 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

It ain't that bad...

 

(defun c:fb (/ block bname)
  (setq block (ssget "_+.:E:S" '((0 . "INSERT"))))  ;; select single entity, for multiple selection its too slow anyway
  (setq bname (cdr (assoc 2 (entget(ssname block 0)))))  ;; index forgotten , 0 is the first
  (command "-bedit" bname )
  (command "change" "all" "" "p" "la" "0" "")
  (command "setbylayer" "all" "" "yes" "yes")
  (command "_.bclose" "_save")  ;; close the editor
  (princ)
  )
Message 3 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous.fahrenkrug wrote:

.... I'm trying to create a lisp that will prompt the user to select a block then edit the block and change all the entities to layer 0 and bylayer. .... 


There are routines out there to do just that, such as this one.  If you'd prefer to adjust yours to work right, you could probably steal elements from it, rather than use it instead of yours.

Kent Cooper, AIA
0 Likes
Message 4 of 7

Anonymous
Not applicable

Dang it. I was so close! I just put WAY to much time into this simple lisp.

 

Thank you for the help BeeKeeCZ!!

0 Likes
Message 5 of 7

Anonymous
Not applicable

I'll have to check out that site. 

 

Thank you. 

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant

@Anonymous.fahrenkrug wrote:

Dang it. I was so close! I just put WAY to much time into this simple lisp.

 

Thank you for the help BeeKeeCZ!!


You're welcome! 

 

If you're able to accept the fact that it was just a good learning lesson, that it worse it! 

If you're able also accept the fact that your routine probably would not be the best one, then you can try enclosed routine(s)... which are so much faster! 

 

- fix a single block

- fix all blocks in the drawing

- fix by sub-entity

0 Likes
Message 7 of 7

Anonymous
Not applicable

Sweet! I need to learn how to make my lisps more like these!

0 Likes