3 offset polyline and snap first polyline

3 offset polyline and snap first polyline

ozcelikfurkan
Observer Observer
1,046 Views
4 Replies
Message 1 of 5

3 offset polyline and snap first polyline

ozcelikfurkan
Observer
Observer

i need 3 offset to the polyline I chose

i want to enter the value in lisp code "ex: 0.05 or 0.1"

I have a code for this

 

(Defun C:O2 (/ p1 ob1)
  (command
    "_.offset" 0.025 (setq ob1 (entsel)) (setq p1 (getpoint)) ""
    "_.chprop" "_last" "" "_layer" "0_SANAL_HAT" ""
    "_.offset" 0.05 ob1 p1 ""
    "_.chprop" "_last" "" "_layer" "0_SANAL_HAT" ""
    "_.offset" 0.075 ob1 p1 ""
    "_.chprop" "_last" "" "_layer" "0_SANAL_HAT" ""

  ); command
  (princ)
);defun

but it doesn't snap the newly created polyline objects to the first polyline object.

i need help with code to snap new objects to old.

0 Likes
Accepted solutions (1)
1,047 Views
4 Replies
  • Snap
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

The image doesn't look like there are 3 Offsets -- is something missing?

 

The image also shows more than just Offsetting and snapping the start [or is it the end?] of the result to that of the source object -- there is at least some Trimming involved.  Is that part of what you're trying to do?  If so, describe the User procedure step by step, including how the Trim boundaries should be determined.

Kent Cooper, AIA
0 Likes
Message 3 of 5

ozcelikfurkan
Observer
Observer

variable offset number. sometimes 1 , 2 or 3. I want 3 offsets. I manually delete more. because it is impossible to do it fully automatically. there are too many variables. My question may not be understood, I prepared an example again.

 

Step 1 : Let me create 3 offsets

Step 2 : Snap the start and end points to the first object

 

I want to edit inside lisp layer information of the created object 

I want to edit inside lisp distance for offset

 

 

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

Try this, which [in minimal testing] moves the end-most vertices of the results of the Offsets to the endmost vertices of the source Polyline.  It assumes a lightweight Polyline, not a "heavy" 2D Polyline.

(vl-load-com)
(defun C:O3C ; = Offset 3 times & Connect ends
  (/ plsel pl1obj pl1Coords pl1CoordsRev pl1Start pl1End)
  (setq
    plsel (entsel "\nPolyline to Offset 3 times and Connect: ")
    pl1obj (vlax-ename->vla-object (car plsel))
    pl1Coords (vlax-get pl1obj 'coordinates)
    pl1CoordsRev (reverse pl1coords)
    pl1Start (list (car pl1Coords) (cadr pl1Coords))
    pl1End (list (cadr pl1CoordsRev) (car pl1CoordsRev))
  ); setq
  (command
    "_.offset" 0.025 plsel (setq p1 (getpoint "\nPoint on side to Offset, far enough away for all 3: ")) ""
    "_.chprop" "_last" "" "_layer" "0_SANAL_HAT" ""
  ); command
  (setq
    pl2obj (vlax-ename->vla-object (entlast))
    pl2Coords (vlax-get pl2obj 'coordinates)
  ); setq
  (vlax-put pl2obj 'coordinates
    (append pl1Start (cddr (reverse (cddr (reverse pl2Coords)))) pl1End)
  ); ...put
  (command
    "_.offset" 0.05 plsel p1 ""
    "_.chprop" "_last" "" "_layer" "0_SANAL_HAT" ""
  ); command
  (setq
    pl2obj (vlax-ename->vla-object (entlast)); re-use variables
    pl2Coords (vlax-get pl2obj 'coordinates)
  ); setq
  (vlax-put pl2obj 'coordinates
    (append pl1Start (cddr (reverse (cddr (reverse pl2Coords)))) pl1End)
  ); ...put
  (command
    "_.offset" 0.075 plsel p1 ""
    "_.chprop" "_last" "" "_layer" "0_SANAL_HAT" ""
  ); command
  (setq
    pl2obj (vlax-ename->vla-object (entlast))
    pl2Coords (vlax-get pl2obj 'coordinates)
  ); setq
  (vlax-put pl2obj 'coordinates
    (append pl1Start (cddr (reverse (cddr (reverse pl2Coords)))) pl1End)
  ); ...put
  (princ)
); defun

For certain configurations, it may give results different from what you intend [yellow is the source Polyline, green the Offset ones]:

Kent1Cooper_0-1671543791331.png

Here, on the left, with an arc segment at an end, the end arc segments in the newer ones keep the bulge factor, not the tangency from the adjacent line segments.  And on the right, the dashed red is the initial result of the third Offset, and since it loses a vertex because of the configuration of the original at that Offset distance, the adjusted left-end green segment of the lowest one is in place of two segments of the others.

Kent Cooper, AIA
Message 5 of 5

ozcelikfurkan
Observer
Observer

yes this is exactly what i want. thank you very much for this.

0 Likes