Block duplication - Within limits

Block duplication - Within limits

k005
Advisor Advisor
1,361 Views
25 Replies
Message 1 of 26

Block duplication - Within limits

k005
Advisor
Advisor

Hello friends;


How can I reproduce the block as I have given in the drawing in the example?

 

 

X distance 45.6

Y distance 45.6

 

In this example, the number of duplicated blocks is 456.

 

* that is, it can exceed the limit by a maximum of 45.6/2. or 45.6/2 in the space within the border.

 

Thanks in advance to the helpful friend.

 

0 Likes
Accepted solutions (1)
1,362 Views
25 Replies
Replies (25)
Message 21 of 26

k005
Advisor
Advisor

'pline not found' I get an error

0 Likes
Message 22 of 26

Sea-Haven
Mentor
Mentor

Ok send sample dwg.

0 Likes
Message 23 of 26

k005
Advisor
Advisor

The first additional example I sent is already

0 Likes
Message 24 of 26

Kent1Cooper
Consultant
Consultant

@k005 wrote:

I can use them as waste in case of overflowing the borders. In your example these appear to be truncated. In this case, the number will be incomplete. Too much is acceptable to some extent. It is unacceptable that it is missing.


The excess/waste part is not missing, it's just masked off.  Yes, they "appear to be truncated," but the Blocks are all there.  If you EXPLODE a Block that crosses the border and is partially masked off, you'll see it all, including the waste portion.  It will no longer be a Block, but maybe that's preferable, if you want to use the waste portion outside the border for something that wants the nested part(s) split off from what's inside the border.

 

SUPERHATCH makes an unnamed Group.  What I haven't found yet in limited trial is a way to un-Group them all and get rid of the masking-off, so you can see the entirety of each Block, still remaining a Block [if that's what you want from it].  Maybe someone out there knows how to do that.  It would make SUPERHATCH the obvious and easiest solution, since it easily handles borders of any kind of shape.

Kent Cooper, AIA
0 Likes
Message 25 of 26

komondormrex
Mentor
Mentor
Accepted solution

hey there,

check the following custom command do_block_boundary_array. block to array better be off the boundary. command will calculate the numbers of instances along x and y axes for the array to fill in the boundary. if you need to, you may increase/decrease each number and see the result.

(defun c:do_block_boundary_array (/ boundary_ename block_ename boundary_extents_list block_extents_list x_block_distance y_block_distance
									x_number_default y_number_default x_number y_number array_block_item to_stay_object_list
									offset_boundary offset_variant init_get
								 )
	(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
	(setq boundary_ename (car (entsel "\nSelect boundary to fill: "))
		  block_ename (car (entsel "\nSelect entity to fill boundary with: "))
	)
	(vla-getboundingbox (vlax-ename->vla-object boundary_ename)  'llc 'ruc)
	(setq boundary_extents_list (list (vlax-safearray->list llc) (vlax-safearray->list ruc)))
	(vla-getboundingbox (vlax-ename->vla-object block_ename)  'llc 'ruc)
	(setq block_extents_list (list (vlax-safearray->list llc) (vlax-safearray->list ruc))
		  init_get (initget 5)
		  x_block_distance (getreal "\nEnter distance between entities by X axis: <0>")
		  init_get (initget 5)
		  y_block_distance (getreal "\nEnter distance between entities by Y axis: <0>")
		  x_number_default (fix (/ (+ (- (caadr boundary_extents_list) (caar boundary_extents_list)) x_block_distance)
		  						   (+ (- (caadr block_extents_list) (caar block_extents_list)) x_block_distance)
							    )
						   )
		  y_number_default (fix (/ (+ (- (cadadr boundary_extents_list) (cadar boundary_extents_list)) x_block_distance)
		  						   (+ (- (cadadr block_extents_list) (cadar block_extents_list)) y_block_distance)
							    )
						   )
		  init_get (initget 5)
		  x_number (getint (strcat "\nEnter number of entities by X axis <"
		  						   (itoa x_number_default)
								   "> :"
						   )
				   )
		  init_get (initget 5)
		  y_number (getint (strcat "\nEnter number of entities by Y axis <"
		  						   (itoa y_number_default)
								   "> :"
						   )
				   )
		  array_block_item (vla-copy (vlax-ename->vla-object block_ename))
	)
	(vla-move array_block_item (vlax-3d-point (trans (car block_extents_list) 1 0))
						   	   (vlax-3d-point (list (+ (caar boundary_extents_list)
						   				 			   (* 0.5 (- (- (caadr boundary_extents_list) (caar boundary_extents_list))
						   				 						 (+ (* x_number (- (caadr block_extents_list) (caar block_extents_list)))
						   				 							 (* (1- x_number) x_block_distance)
						   				 						 )
						   				 					  )
						   				 			   )
						   			  	 			)
						   			  	 			(+ (cadar boundary_extents_list)
						   			  				   (* 0.5 (- (- (cadadr boundary_extents_list) (cadar boundary_extents_list))
						   			  					 		 (+ (* y_number (- (cadadr block_extents_list) (cadar block_extents_list)))
						   			  								(* (1- y_number) y_block_distance)
						   			  							 )
						   			  						  )
						   			  					)
						   			  	 			)
						   				       )
						   	   )
	)
  	(setq array_list (vlax-safearray->list (vlax-variant-value (vla-arrayrectangular array_block_item
	 										 y_number
	 										 x_number
	 										 1
											 (+ y_block_distance (- (cadadr block_extents_list) (cadar block_extents_list)))
	 										 (+ x_block_distance (- (caadr block_extents_list) (caar block_extents_list)))
	 										 0
					   			   )
				 	       )
			 )
	)
	(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport)
	(if (> x_number x_number_default)
			(progn
				(setq offset_value (* 0.5 (- x_number x_number_default) (+ (- (caadr block_extents_list) (caar block_extents_list)) x_block_distance)))
				(if (< (vla-get-area (setq offset_boundary (car (vlax-safearray->list (vlax-variant-value (setq offset_variant (vla-offset (vlax-ename->vla-object boundary_ename) offset_value)))))))
					   (vla-get-area (vlax-ename->vla-object boundary_ename))
					)
						(progn
							(mapcar 'vla-erase (vlax-safearray->list (vlax-variant-value offset_variant)))
							(setq offset_boundary (car (vlax-safearray->list (vlax-variant-value (vla-offset (vlax-ename->vla-object boundary_ename) (* -1 offset_value))))))
						)
				)
			)
	)
	(setq to_stay_object_list (mapcar 'vlax-ename->vla-object
					   (vl-remove-if 'listp
							  (mapcar 'cadr
						  		   (ssnamex (ssget "_wp"
						   				   (mapcar 'cdr
									   			(vl-remove-if-not '(lambda (dxf_group) (= 10 (car dxf_group)))
							   							   (if (null offset_boundary)
														   			(entget boundary_ename)
																	(entget (vlax-vla-object->ename offset_boundary))
														   )
												)
										   )
									    )
								   )
							  )
					   )
				   )
	)
	(foreach object array_list
		(if (not (member object to_stay_object_list))
				(vla-erase object)
		)
	)
	(if offset_boundary (vla-erase offset_boundary))
;;;	(vla-erase array_block_item)
	(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
	(princ)
)
Message 26 of 26

k005
Advisor
Advisor

It was a very nice solution. Thank you very much. Ok.

0 Likes