Draw line between insertion point of a block and other point at the same block

Draw line between insertion point of a block and other point at the same block

RBernaz
Advocate Advocate
2,374 Views
28 Replies
Message 1 of 29

Draw line between insertion point of a block and other point at the same block

RBernaz
Advocate
Advocate

Hi,

 

Hope someone can help me since my lisp knowledges are very poor.

 

I have a dynamic block to insert multiple along a line and I already inserted, but now i would like to draw a line between the insertion point of it to another point of itself. Could be done all together at the same time or by picking one by one.

 

Example: Have a line and i’ve inserted perpendiculary 10 blocks like balloons which the insertion point is the start of the rope and then we have balloon itself… I would like to automatically draw in each block a line between the start of the rope and the center of the balloon….

 

Is it possible ???

 

Hope you understand what I mean

 

Thanks in advance

 

Best regards

0 Likes
Accepted solutions (1)
2,375 Views
28 Replies
Replies (28)
Message 2 of 29

devitg
Advisor
Advisor

Please upload a BEFORE and AFTER DWG .

0 Likes
Message 3 of 29

ВeekeeCZ
Consultant
Consultant

Post the dwg with that block and draw a line where you what to have it.

0 Likes
Message 4 of 29

RBernaz
Advocate
Advocate

thank you,

 

There is the example file. The red lines are the those to be drawn, after inserting the blocks

 

hope it helps

0 Likes
Message 5 of 29

RBernaz
Advocate
Advocate

and the line where we insert the blocks will not always be horizontal or vertical it can be i irregular path

0 Likes
Message 6 of 29

devitg
Advisor
Advisor

show as it will be .

0 Likes
Message 7 of 29

RBernaz
Advocate
Advocate

I've already posted a file example

 

thanks

0 Likes
Message 8 of 29

Moshe-A
Mentor
Mentor

@RBernaz  hi,

 

if the line is drawn from the insertion point to center of balloon then why can't you add it as part of the block?

 

 

0 Likes
Message 9 of 29

RBernaz
Advocate
Advocate

thank you,

Because the lines have to be available to be manipulated independtly after the insertion of the block

0 Likes
Message 10 of 29

RBernaz
Advocate
Advocate

It´s easy when you have a few but when you have hundres is painfull

0 Likes
Message 11 of 29

Moshe-A
Mentor
Mentor

yes but we are talking about LINE and the manipulation you want to do is move the first point (assuming the second point must be in center of the balloon) and you can enable this manipulation in dynamic block

also you can add visibility param to turn the line on\off - no?

 

 

 

 

0 Likes
Message 12 of 29

RBernaz
Advocate
Advocate

yes, but you cannot do an offset from it or change color or layer independently if it is inside of the block...

0 Likes
Message 13 of 29

Moshe-A
Mentor
Mentor

that is not true, with dynamic block tools you can simulate even offset and change the line layer and color

 

0 Likes
Message 14 of 29

RBernaz
Advocate
Advocate

Well the offset, yes I can do with visibility and manipulate by stretching parameters, but colour by layer, layer and plot style? can I?

0 Likes
Message 15 of 29

RBernaz
Advocate
Advocate

well i can do a block with the block and the line inside and then explode all of them after inserting them all....

I realized that now maybe it is easier 

 

thank you all

0 Likes
Message 16 of 29

Moshe-A
Mentor
Mentor

well if you design the block carefully by laying the rectangle on fixed layer and the line lay on layer '0' plus set it's color 'byblock' than by changing the block layer the line will reflect this layer change and changing the block color the line will reflect that color.

 

0 Likes
Message 17 of 29

Moshe-A
Mentor
Mentor

no no no !

there is huge advantage on keeping it as block cause any change will reflect all inserts

 

 

Message 18 of 29

Moshe-A
Mentor
Mentor
Accepted solution

@RBernaz hi,

 

just for i do not want you to leave with bitter taste, here is the lisp function to do what you want

to control layer + color and ltype you need to set the appropriate fields in (entmake) function:

 

(cons 8 (getvar 'clayer)) ; set layer

'(6 . "bylayer") ; set ltype bylayer

'(62 . 256) ; set color bylayer

 

for example:

(cons 8 "wire") ; lay the line on layer wire

'(6 . "dashdot") ; set linertype dashdot

'(62 . 1) ; set line color to red

 

of course you can change all of these properties afterwards.

 

enjoy

moshe

 

 

(defun c:bwire (/ ss AcDbBlockReference elist dyn_length dyn_angle p0)
 (if (setq ss (ssget '((0 . "insert") (2 . "square,`*U*"))))
  (mapcar
    '(lambda (ename)
      (if (and
	    (setq AcDbBlockReference (vlax-ename->vla-object ename)); allocating memmory
	    (eq (vla-get-isDynamicBlock AcDbBlockReference) :vlax-true)
	    (eq (strcase (vla-get-effectivename AcDbBlockReference)) "SQUARE")
	  )
       (progn
	(setq elist (entget ename))
        (setq dyn_length (getpropertyvalue ename "AcDbDynBlockPropertyImplantação"))
	(setq dyn_angle  (getpropertyvalue ename "AcDbDynBlockPropertyAngle2"))
	(if (= (getpropertyvalue ename "AcDbDynBlockPropertyFlip State1") 1)
	 (setq dyn_angle (+ dyn_angle pi))
	)

	; add line to drawing
	(entmake (list
		  '(0 . "line")
		   (cons 8 (getvar 'clayer))	; set layer
		  '(6  . "bylayer")		; set ltype bylayer
		  '(62 . 256)			; set color bylayer
		   (cons 10 (setq  p0 (cdr (assoc '10 elist))))
		   (cons 11 (polar p0 (+ (cdr (assoc '50 elist)) dyn_angle) dyn_length))
		 )
	); entmake
       ); progn
      ); if

      (vlax-release-object AcDbBlockReference) ; dispose memory
     ); lambda
    (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
  ); mapcar
 ); if

 (princ) 
); c:bwire
Message 19 of 29

RBernaz
Advocate
Advocate

Fantastic, wonderful, many thanks for the solution.

0 Likes
Message 20 of 29

devitg
Advisor
Advisor

Hi Moshe-A, I do not know nothing about dynamic block , but could it be a way to edit the block or rename , and the line to be in the dynamic block  with it's length and flip tobe variable??

Maybe I can start learning about dyn Blocks.

 

0 Likes