Count all 3D-Solids, Blocks and write their Dimensions

Count all 3D-Solids, Blocks and write their Dimensions

Emi_Riv
Contributor Contributor
805 Views
7 Replies
Message 1 of 8

Count all 3D-Solids, Blocks and write their Dimensions

Emi_Riv
Contributor
Contributor

Dear all

 

I need always a lot of time to count my Blocks in a 3d-draw, aswell i need to write there dimensions.

I don't know if its posible to do this with a lisp. 

I found out how i can read the values, but only from one 3d-shape. (Lisp attached)

But I don't know how to make a loop so that it affects to all objects.

Maybe someone can make a fusion/merge with the lisp (Blockcounter) from dlanorh? (Aswell Attached)

 

A lot thanks for all inputs and your helps.

 

Situation.jpg

0 Likes
Accepted solutions (1)
806 Views
7 Replies
Replies (7)
Message 2 of 8

Sea-Haven
Mentor
Mentor

You have 3dsolids as boxes so len wid ht is easy if they are some unioned shape then the bounding box is all you can get as a simple answer. 

 

So you only want 3d solids ?

 

There is a count rectangs out there so a third parameter Z ht could be added.

 

I know did for Foam pad.dwg will try to find code again. 

0 Likes
Message 3 of 8

Sea-Haven
Mentor
Mentor

Found it under a user name, just need to confirm 3d solids just using the overall measurements. I will need to add the Z parameter. It sorts length and width swapping them so takes into account rotated object of same size. Can remove that option.

 

 

0 Likes
Message 4 of 8

Emi_Riv
Contributor
Contributor

Hi Sea-Haven

 

First a big thanks for your time and help.🤗

The "foampad"-Lisp is exactly what i need of course with high (z).

Unfortunately i couldn't find the lisp in the internet. Can you post it?

0 Likes
Message 5 of 8

pbejse
Mentor
Mentor
Accepted solution
(defun c:SolidBlocks ( / msp blks objects pt i obj MIP MAP x y z data blk_lst DataTable row col)
(or *adoc* (setq *adoc* (vla-get-activedocument (vlax-get-acad-object))))
(setq msp    (vla-get-modelspace *adoc*))
(if (and
      (setq objects (ssget '((0 . "INSERT,3DSOLID"))))
      (setq pt (getpoint "\nSelect Table Location : "))
     	)	
  (progn
	(repeat (setq i (sslength objects))
		(setq obj (vlax-ename->vla-object (ssname objects (setq i (1- i)))))
		;;		From Dimensions lisp		;;
		(vla-GetBoundingBox obj 'minpoint 'maxpoint)
		(setq MIP (vlax-safearray->list minpoint))
		(setq MAP (vlax-safearray->list maxpoint))
		(setq x (- (car MAP) (car MIP)))
		(setq y (- (cadr MAP) (cadr MIP)))
		(setq z (- (caddr MAP) (caddr MIP)))
	  	;;		From Dimensions lisp		;;
	  	(setq data (list
				  (cond
				    ( (eq "AcDbBlockReference" (setq objname (vla-get-objectname obj)))
					(vlax-get obj (if (vlax-property-available-p obj 'effectivename
								) 'effectivename 'name
							    )
						  )
				     )
				    (	(eq "AcDb3dSolid" objname) "3D Solid"))
			    (rtos x 2 0) (rtos y 2 0) (rtos z 2 0)))
		(setq blk_lst
		  	(if (not (setq f (assoc data blk_lst)))
			  	(cons (list data 1) blk_lst)
			  	(subst (list data (1+ (cadr f))) f  blk_lst)))	  
		  )
    		(setq blk_lst (vl-sort blk_lst '(lambda (j k )(< (caar j)(caar k)))))
		(setq DataTable (vla-addtable msp (vlax-3d-point pt) 2 6 8.5 230))
		(vla-put-regeneratetablesuppressed DataTable :vlax-true)
    		(if (= actitlerow (vla-getrowtype DataTable 0)) (vla-DeleteRows DataTable 0 1))
	(mapcar '(lambda (y)
	  	(vla-settext DataTable 0 (car y) (cadr y))
	  	(vla-setcelltextheight DataTable 0 (car y) 3.00)
                       )
		 '((0 "")(1 "Object/Block name")(2 "Count")(3 "Length X")(4 "Width X")(5 "High Z"))
		)
      (vla-SetColumnWidth DataTable 0 15.0)
      (setq col 0)
      (repeat 5
          (vla-SetColumnWidth DataTable (Setq col (1+ col)) 42.00)
	)
       (vla-SetRowHeight DataTable 0 8.5)
    
      (vla-InsertRowsAndInherit DataTable 1 0 (length blk_lst))
      (setq row 1)
      (foreach itm blk_lst
	(setq objData (Car itm))
	(mapcar '(lambda (d n)
	  (vla-settext DataTable row n d))
		(append (list (itoa row)(car objData)(itoa (cadr itm)) )(cdr objData))
		'(0 1 2 3 4 5))
	(setq row (1+ row))
	)
      (vla-put-regeneratetablesuppressed DataTable :vlax-false)
      )
    )
(princ)      
    )

HTH

 

Message 6 of 8

Sea-Haven
Mentor
Mentor

Thanks pbe you have answered a much simpler method of counting similar lists, the way I was doing was much more complicated.

Message 7 of 8

Emi_Riv
Contributor
Contributor

Thank you a lot @pbejse.

I don't rotate the solids so it works perfectly for me.

 

Here i found an other super tool, to find all Elements in a work:

https://apps.autodesk.com/ACD/de/Detail/Index?id=4521520962883858766&appLang=en&os=Win32_64

0 Likes
Message 8 of 8

pbejse
Mentor
Mentor

@Emi_Riv wrote:

Thank you a lot pbejse.

I don't rotate the solids so it works perfectly for me.

Great, glad it helps.

Cheers

0 Likes