Jump to content

LEE MAC ,about dynamic block countV1.lisp


Recommended Posts

o0ki1ler

hello ,LEE MAC ,I take the liberty to write this letter to you about your LISP program for dynamic block countV1, which does not support dynamic stretching. I am a novice myself. I have not worked it out for a long time. I want to get your help. I wonder if you have time to update this program. Thank you!

Link to post
Share on other sites
BIGAL

If I understand correct you want the total of the number of blocks with the same length value.

 

(defun c:blkcnt ( / lst ss blk val )
  (setq lst '() lst2 '() lst3 '())
  (setq ss (ssget (list (cons 0 "INSERT")(cons 2 "*U*"))))
  (repeat (setq x (sslength ss))
    (setq blk (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
    (setq val (LM:getdynpropvalue  blk   "规格"))
    (setq lst (cons val lst))
  )
  (setq lst2 (remove_doubles lst))
  (foreach len lst2
    (setq cnt (my-count len lst))
    (setq lst3 (cons (list len cnt) lst3))
  )
(princ)
)
(c:blkcnt)

image.png.db21de8be2740626218a707e1b5dd86e.png

 

(princ lst3)

((1800.0 2) (1200.0 4) (2000.0 5))

Link to post
Share on other sites
o0ki1ler

Yes, but I tested it with your code, and there was no way to select the layer. I don't know why.

On 10/17/2021 at 11:55 AM, BIGAL said:

If I understand correct you want the total of the number of blocks with the same length value.

 



(defun c:blkcnt ( / lst ss blk val )
  (setq lst '() lst2 '() lst3 '())
  (setq ss (ssget (list (cons 0 "INSERT")(cons 2 "*U*"))))
  (repeat (setq x (sslength ss))
    (setq blk (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
    (setq val (LM:getdynpropvalue  blk   "规格"))
    (setq lst (cons val lst))
  )
  (setq lst2 (remove_doubles lst))
  (foreach len lst2
    (setq cnt (my-count len lst))
    (setq lst3 (cons (list len cnt) lst3))
  )
(princ)
)
(c:blkcnt)

image.png.db21de8be2740626218a707e1b5dd86e.png

 

(Princ Lst 3)

((1800.0 2) (1200.0 4) (2000.0 5))

 

Edited by o0ki1ler
Link to post
Share on other sites
BIGAL

I have updated the code above I am not sure what you want as output so if you type !lst3 after running you will see result. The sort does not like the non english characters so I removed and works on your new dwg.

Link to post
Share on other sites
o0ki1ler

I come from China, and I'm not very good at English, but it doesn't affect programming. Just replace the Chinese characters in the block with letters!

Link to post
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
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...