Jump to content

Lisp works only when certain conditions are established...


cadmaster1004

Recommended Posts

Hi, guys. I want to ask you a question.


There's a block named A
And there's a block with names A, B, C, D
First, select block A and then block A, B, C, and D at once (mouse drag)
I'm looking for a lisp that generates text only on block A
In other words, I want to study Lisp that only works on block A.

Please take good care of me. I hope you stay healthy!

Edited by cadmaster1004
Link to comment
Share on other sites

8 hours ago, cadmaster1004 said:

Hi, guys. I want to ask you a question.


There's a block named A
And there's a block with names A, B, C, D
First, select block A and then block A, B, C, and D at once (mouse drag)
I'm looking for a lisp that generates text only on block A
In other words, I want to study Lisp that only works on block A.

Please take good care of me. I hope you stay healthy!

As far as I know , you can have only one block named A . please upload sample-dwg ,  before and after . 

 

Link to comment
Share on other sites

11 hours ago, devitg said:

As far as I know , you can have only one block named A.

 

One definition of block A in the block library, But you can have multiples of block A in the drawing.

 

20 hours ago, cadmaster1004 said:

I'm looking for a lisp that generates text only on block A

In other words, I want to study Lisp that only works on block A.

 

This should be what your looking for. Added two other lisp that will dump properties of selected items into command prompt.

dumpit = dxf codes

Vdumpit = visual lisp propeties

 

;;----------------------------------------------------------------------;;
;; Select Block by Name
(defun C:SBN (/ blkname SS)
  (setq blkname (cdr (assoc 2 (entget (car (entsel "\nSelect Block")))))) ;Gets block name to use in ssget filter
  (if (setq SS (ssget (list '(0 . "INSERT") (cons 2 blkname)))) ;will only select blocks of the same name
    (sssetfirst nil SS)  
  )
  (princ)
)

;;----------------------------------------------------------------------------;;
;; Dump all methods and properties for selected objects               
(defun C:VDumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t)
  )
  (textscr)
  (princ)
)
;;----------------------------------------------------------------------------;;
;; Dump all DXF Group Data             
(defun C:DumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (mapcar 'print (entget ent '( "*")))
  )
  (textscr)
  (princ)
)

 

 

Edited by mhupp
  • Like 3
Link to comment
Share on other sites

1 hour ago, devitg said:

As far as I know , you can have only one block named A . please upload sample-dwg ,  before and after . 

 

 

I took that to mean select block A to be the reference block and then select all blocks, filtering so that only instances of block A are selected. Like MHUPP says, you can have many instances of a block inserted (but only 1 definition of it)

Edited by Steven P
Link to comment
Share on other sites

I am sorry for my poor English.
But thank you for letting me know.
I'll study it with that cord

6 hours ago, mhupp said:

 

One definition of block A in the block library, But you can have multiples of block A in the drawing.

 

 

This should be what your looking for. Added two other lisp that will dump properties of selected items into command prompt.

dumpit = dxf codes

Vdumpit = visual lisp propeties

 

;;----------------------------------------------------------------------;;
;; Select Block by Name
(defun C:SBN (/ blkname SS)
  (setq blkname (cdr (assoc 2 (entget (car (entsel "\nSelect Block")))))) ;Gets block name to use in ssget filter
  (prompt "\nSelect Polyline")
  (if (setq SS (ssget (list '(0 . "INSERT") (cons 2 blkname)))) ;will only select blocks of the same name
    (sssetfirst nil SS)  
  )
  (princ)
)

;;----------------------------------------------------------------------------;;
;; Dump all methods and properties for selected objects               
(defun C:VDumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t)
  )
  (textscr)
  (princ)
)
;;----------------------------------------------------------------------------;;
;; Dump all DXF Group Data             
(defun C:DumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (mapcar 'print (entget ent '( "*")))
  )
  (textscr)
  (princ)
)

 

 

 

Link to comment
Share on other sites

Maybe this will make a selection set of blocks with 1 name only.

 

(setq BNAME (cdr (assoc 2 (entget (car (entsel "\nPick block for name "))))))
(setq ss (ssget (list (cons 0 "INSERT")(cons 2 bname))))

 

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