TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mohan on November 25, 2021, 03:57:09 AM

Title: Find the block in which layout
Post by: mohan 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))
Title: Re: Find the block in which layout
Post by: Lee Mac 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. )
Title: Re: Find the block in which layout
Post by: Tharwat 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. )
Title: Re: Find the block in which layout
Post by: mohan 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: