Pick a point between polylines then create internal polylne with radius 50.0

Pick a point between polylines then create internal polylne with radius 50.0

J-Rocks
Collaborator Collaborator
588 Views
9 Replies
Message 1 of 10

Pick a point between polylines then create internal polylne with radius 50.0

J-Rocks
Collaborator
Collaborator

Hi,

 

I am having a hard time to know to to be able to create a internal polyline between polylines with fillet of 50.0 units as in the attached image and drawing.

 

Hope someone to help me with this.

 

Thanks in advance.

 

Drawing1-Model.jpg

0 Likes
589 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant

Guess you are talking about offset............

 

(vl-load-com)
(defun c:IntOffset50 ( / pt)
  (if (setq pt (getpoint "\nInternal point: "))
    (progn
      (setvar 'FILLETRAD 50)
      (vl-cmdf "_.-BOUNDARY" "_none" pt "")
      (vl-cmdf "_.OFFSET" "_Erase" "_Y" 50 (entlast) pt "")
      (vl-cmdf "_.FILLET" "_Polyline" "_Last")
      ))
  (princ)
)
0 Likes
Message 3 of 10

J-Rocks
Collaborator
Collaborator

Thank you for your reply.

 

I need to pick a point in an opened area and your program does not work for this case. 

Can you please modify your codes ?

 

Thanks

0 Likes
Message 4 of 10

ВeekeeCZ
Consultant
Consultant

@J-Rocks wrote:

 

...

I need to pick a point in an opened area and your program does not work for this case. 

Can you please modify your codes ?

 

...

Not that simple. 

But you can try this approach. If an area is opened, you will close it first - you'll select a first end, then a second - couter-clockwise!, and that's all you need to do.

 

Spoiler
(vl-load-com)

(defun c:IntOffset50 ( / *error* nVAR oVAR adoc p1 p2 pt enl)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (mapcar 'setvar nVAR oVAR)
    (vla-endundomark adoc)
    (princ))
  
  (vla-startundomark (setq adoc (vla-get-activedocument (setq aapp (vlax-get-acad-object)))))
  (setq oVAR (mapcar 'getvar (setq nVAR '(CMDECHO OSMODE ORTHOMODE SNAPMODE BLIPMODE FILLETRAD))))
  (mapcar 'setvar nVAR 			'(1	  33	 0	   0        0	     50))
  
  (if (and (setq p1 (getpoint "\nSelect first end of line (counter-clockwise) to close the area <area is closed>: "))
	   (setq p2 (getpoint p1 "\nSelect second end: "))
	   )
    (progn
      (setvar 'OSMODE 0)
      (vl-cmdf "_.LINE" p1 p2 "")
      (setq enl (entlast)
	    pm (polar p1 (angle p1 p2) (* (distance p1 p2) 0.5))
	    pt (polar pm (+ (angle p1 p2) (* pi 0.5)) 50))))
  
  (if (or pt
	  (setq pt (getpoint "\nInternal point: ")))
    (progn
      (vl-cmdf "_.-BOUNDARY" pt "")
      (if (and enl (entget enl)) (entdel enl))
      (vl-cmdf "_.TRIM" "" pm "")
      (vl-cmdf "_.OFFSET" "_Erase" "_Y" 50 (entlast) pt "")
      (vl-cmdf "_.OFFSET" "_Erase" "_N" "" "")
      (vl-cmdf "_.FILLET" "_Polyline" "_Last")
      ))
  (princ)
)
0 Likes
Message 5 of 10

J-Rocks
Collaborator
Collaborator

Hello,

 

You changed the settings of my AutoCAD and did not re-set them back Smiley Frustrated

I am sorry I can not close the area.

 

Thanks for trying.

0 Likes
Message 6 of 10

ВeekeeCZ
Consultant
Consultant

@J-Rocks wrote:

Hello,

 

You changed the settings of my AutoCAD and did not re-set them back Smiley Frustrated

I am sorry I can not close the area.

 

Thanks for trying.


I see, sorry, not on purpose. One line missing. :(( I asked the modarator to remove the code.

 

Spoiler
(vl-load-com)

(defun c:IntOffset50 ( / *error* nVAR oVAR adoc p1 p2 pt enl)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (mapcar 'setvar nVAR oVAR)
    (vla-endundomark adoc)
    (princ))
  
  (vla-startundomark (setq adoc (vla-get-activedocument (setq aapp (vlax-get-acad-object)))))
  (setq oVAR (mapcar 'getvar (setq nVAR '(CMDECHO OSMODE ORTHOMODE SNAPMODE BLIPMODE FILLETRAD))))
  (mapcar 'setvar nVAR 			'(1	  33	 0	   0        0	     50))
  
  (if (and (setq p1 (getpoint "\nSelect first end of line (counter-clockwise) to close the area <area is closed>: "))
	   (setq p2 (getpoint p1 "\nSelect second end: "))
	   )
    (progn
      (setvar 'OSMODE 0)
      (vl-cmdf "_.LINE" p1 p2 "")
      (setq enl (entlast)
	    pm (polar p1 (angle p1 p2) (* (distance p1 p2) 0.5))
	    pt (polar pm (+ (angle p1 p2) (* pi 0.5)) 50))))
  
  (if (or pt
	  (setq pt (getpoint "\nInternal point: ")))
    (progn
      (vl-cmdf "_.-BOUNDARY" pt "")
      (if (and enl (entget enl)) (entdel enl))
      (vl-cmdf "_.TRIM" "" pm "")
      (vl-cmdf "_.OFFSET" "_Erase" "_Y" 50 (entlast) pt "")
      (vl-cmdf "_.OFFSET" "_Erase" "_N" "" "")
      (vl-cmdf "_.FILLET" "_Polyline" "_Last")
      ))
  (*error* "end")
)

Why? On your sample that works perfectly. Or is your sample to simplified?

0 Likes
Message 7 of 10

J-Rocks
Collaborator
Collaborator

No it is not simplified sample , it is as reality.

 

After closing the opened area, the opening new polyline does not direct the open segment of it to the correct side.

0 Likes
Message 8 of 10

ВeekeeCZ
Consultant
Consultant

@J-Rocks wrote:

... 

After closing the opened area, the opening new polyline does not direct the open segment of it to the correct side.


Could be that fixed by reversing the polyline? If so, could you explain how to recognise which direction is correct?

0 Likes
Message 9 of 10

J-Rocks
Collaborator
Collaborator

Hello.

 

I expected from the program to recognise which direction is correct and really I have no idea.

0 Likes
Message 10 of 10

Kent1Cooper
Consultant
Consultant

@J-Rocks wrote:

.... 

After closing the opened area, the opening new polyline does not direct the open segment of it to the correct side.


If I understand how it works correctly, that would happen if you didn't follow the instruction to close the area with a Line going in the counter-clockwise direction.  Might you have picked the points for the closing Line in the wrong order?  But then, I would also expect the Boundary command to have a problem, because it looks like the point it would use to pick the area [the same one it uses for the Offset command] should be outside it, also....

 

One thing I have sometimes done in a similar situation, that doesn't depend on the direction in which a Polyline is drawn, is to use (vla-offset), which doesn't use a point to determine the direction of offset, but uses a positive or negative distance value.  Then I compare the Area of the resulting one to that of the original -- if the new one is smaller, it went inside, or if it's larger, it went outside.  If it went the wrong way for whatever the routine is doing, I have it delete that result, and do (vla-offset) again with the opposite sign on the distance value.

Kent Cooper, AIA
0 Likes