Draw lines on blocks in drawing.

Draw lines on blocks in drawing.

Dan-Rod
Advocate Advocate
808 Views
9 Replies
Message 1 of 10

Draw lines on blocks in drawing.

Dan-Rod
Advocate
Advocate

Draw lines on blocks in drawing.

I have blocks in a drawing that generally represent lines in my projects, these, you have to stay like this but I want to see if it is possible to draw polylines on these to have the 2 options, is there any autocad or lsp macro that can do it?

0 Likes
Accepted solutions (1)
809 Views
9 Replies
Replies (9)
Message 2 of 10

ec-cad
Collaborator
Collaborator

In the drawing sample, I don't see what the 2 options are. ?

Could you explain what you want there ?

 

ECCAD

0 Likes
Message 3 of 10

Kent1Cooper
Consultant
Consultant

Are the "2 options" a distinction between those made up of a series of Blocks that consist of

1.  an outline rectangle Polyline without with zero width, and a single-segment Polyline with width filling it in, vs.

2.  Lines at the ends, with six SOLID Hatch patterns filling in the space between them

?

 

And are the Lines that the Blocks "generally represent" supposed to be [I'll guess] single Lines along the middle of a long series of Blocks in a row, or along edges where some of the Blocks contain Line objects, or... ?  I'm having a hard time imagining how a routine would identify the ones to draw a Line over collectively, if that's even what you intend.

 

Draw in some of the Lines you intend, make it clear where they are and how they relate to the Blocks, label things, and post the drawing again.

Kent Cooper, AIA
0 Likes
Message 4 of 10

Dan-Rod
Advocate
Advocate

Thanks @Kent1Cooper  @ec-cad   you for taking the time to see the case, I attach the file with the updated example, I hope it is clearer

0 Likes
Message 5 of 10

pendean
Community Legend
Community Legend

So you want these 153 blocks of rectangular filled shaped to be converted to Lines/PLINEs with the same shape (or have a Line/PLINE drawn over them by a LISP)

pendean_0-1727383072075.png

pendean_1-1727383137546.pngpendean_3-1727383232294.png

 

pendean_2-1727383183577.png

 

0 Likes
Message 6 of 10

Dan-Rod
Advocate
Advocate

Yes, these blocks represent lines that carry attributes or characteristics that a polyline cannot carry, but doing the conversion makes it easier to map or route these blocks.

0 Likes
Message 7 of 10

Kent1Cooper
Consultant
Consultant

I see some things that will make this pretty close to impossible.  In the one little part where you drew the white Polylines over the grey Blocks:

Kent1Cooper_1-1727457472058.png

most of the Blocks are duplicated, almost but not quite in the same place.  This selection is two Blocks on top of each other:

Kent1Cooper_0-1727457420733.png

[and note that the Polylines don't meet], but their insertion points are not the same, and neither one is on the line:

Kent1Cooper_2-1727457610747.png

And I found at least one place where the series of Blocks in a straight row, presumably to be drawn over with one line, has a reversal of rotation midway, a point where two Blocks are inserted at the same place but have opposite rotations, and there are two rows of Block progressing in opposite directions from there.

 

Even with such peculiarities corrected, it looks like a staggeringly complex task, to get a routine to be able to detect which Blocks belong together in sets, with the same rotation, and collinear insertion points, and presumably some kind of adjacency or spacing test, made more difficult by the varying scale factors.  And they're not always in drawn order in a given row, either, so determining the extent within a set [which two Blocks are the ends of the row?] would be another challenge.  Even after figuring that out, there's the further complication that each Line would need to extend not just between the endmost insertion points in a row, but at one end through the width of the last Block to the far side midpoint [a different distance as the scale factors vary].  That is sometimes the location of an end of a Line over a different row of Blocks, but it might be the through-to-the-other-side midpoint for both rows, i.e. with no insertion point at all there.  If they should be Polylines, determining which sets meet in the right way at which ends is another problem -- it would probably be better to do Lines, and join those that can be joined after the fact.

 

With only MIDpoint Object Snap running, you could draw a powerful lot of these Lines/Polylines in the time it would take to work out a routine to automate the process, if that's even really possible.  [In your original drawing, MIDpoint alone wouldn't do for one of the Block types, because it would latch onto an off-center location relative to the overall Block, but ENDpoint or INTersection would be needed.]

Kent Cooper, AIA
0 Likes
Message 8 of 10

komondormrex
Mentor
Mentor
Accepted solution

check this quick shot

(defun c:blocks_to_lines (/ ok_lines_sset blocks_sset ok_lines_list insertion_point)
  (prompt "\nSelect blocks to translate to lines...")
  (vla-startundomark (vla-get-activedocument (vlax-get-acad-object))) 
  (if (setq ok_lines_sset (ssadd) blocks_sset (ssget '((0 . "insert") (2 . "block"))))
    	(progn
		(setq ok_lines_list  
		  	(mapcar '(lambda (insert) (vla-addline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
						    		(vlax-3d-point (setq insertion_point (cdr (assoc 10 (entget insert)))))
						    		(vlax-3d-point (polar insertion_point (cdr (assoc 50 (entget insert))) (* 7.5 (cdr (assoc 42 (entget insert))))))
						  )
				 )
				 (vl-remove-if 'listp (mapcar 'cadr (ssnamex blocks_sset)))
			)
	        )
		(foreach line ok_lines_list
			(ssadd (vlax-vla-object->ename line) ok_lines_sset)
	  	)
		(command "_-overkill" (eval ok_lines_sset) "" "_tol" 7.5 "")
	  	(command "_erase" blocks_sset "")
      )
  )
  (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
  (prompt "\nSelected blocks translated to lines. Manual fine tuning may be needed.")
  (princ)
)
0 Likes
Message 9 of 10

Dan-Rod
Advocate
Advocate

All your comments are correct, precisely for this reason I was looking for the conversion to lines since it is more friendly to carry out the processes that I need in a separate drawing, leaving the original blocks as they are needed, I appreciate the time you took in the observations.

0 Likes
Message 10 of 10

Dan-Rod
Advocate
Advocate

Thanks, I converted each block to lines, this lsp serves the purpose

0 Likes