Author Topic: Find the block in which layout  (Read 1175 times)

0 Members and 1 Guest are viewing this topic.

mohan

  • Newt
  • Posts: 98
Find the block in which layout
« on: November 25, 2021, 03:57:09 AM »
Code fixing please
Block Name: "A$C1A300073"

Code: [Select]
(defun c:blockfind ( / ss )
(vl-some '(lambda (layout)
(if (setq ss (ssget "X" (list (cons 2 "A$C1A300073") (cons 67 1) (cons 410 layout))))
(list ss layout)))
(layoutlist)) (princ))
"Save Energy"

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Find the block in which layout
« Reply #1 on: November 25, 2021, 07:15:47 AM »
It's likely easier to approach it this way:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / s )
  2.     (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "A$C1A300073"))))
  3.         (princ (cdr (assoc 410 (entget (ssname s 0)))))
  4.         (princ "\nBlock not found.")
  5.     )
  6.     (princ)
  7. )

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Find the block in which layout
« Reply #2 on: November 25, 2021, 07:18:08 AM »
Your codes search only in Paper spaces so you need to bring the result from the vl-some function out to publicity to know the outcome.  :grinwink:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:blockfind (/ ss lst)
  2.   (vl-some '(lambda (layout)
  3.               (if (setq ss (ssget "X"
  4.                                   (list (cons 2 "A$C1A300073")
  5.                                         (cons 67 1)
  6.                                         (cons 410 layout)
  7.                                   )
  8.                            )
  9.                   )
  10.                 (setq lst (list ss layout))
  11.               )
  12.             )
  13.            (layoutlist)
  14.   )
  15.   lst
  16. )

mohan

  • Newt
  • Posts: 98
Re: Find the block in which layout
« Reply #3 on: November 25, 2021, 12:33:25 PM »
It's likely easier to approach it this way:

Your codes search only in Paper spaces so you need to bring the result from the vl-some function out to publicity to know the outcome.  :grinwink:

Thank you so much . . . :smitten:
"Save Energy"