Jump to content

Offset & Stretch


Yirmeyahu

Recommended Posts

I am having trouble offsetteing a pline 6" and stretching the end points 6" after the pline has been exploded.  Here is what I have so far.

 

 

 


(defun C:DRW (/ ss n m sss)
 (command "._undo" "_begin")
 
   (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'osmode 'cmdecho)
        sv_vals (mapcar 'getvar sv_lst)
        blk "DRW"  
    )
  (command "-layer" "m" "tempPB" "Color" "cyan" "" "Plot" "Plot" "" "Ltype" "continuous" "" "")
  (command "-layer" "thaw" "Anchor Bolt" "m" "Anchor Bolt" "Color" "blue" "" "Plot" "Plot" "" "Ltype" "continuous" "" "")
  
  (setq maxSpcng (getdist "\nPick or enter spacing or <6'>: "))
    (if (= maxSpcng nil)(setq maxSpcng 72))
  
  (if (setq ss (ssget "_:L" '((0 . "*POLYLINE") (8 . "Anchor Bolt")) ))
    
    (repeat (setq n (sslength ss)); repeat each edge
      
      (command "_.COPY" (ssname ss (setq n (1- n))) "" "0,0" "0,0")
      (command "_.chprop" "L" "" "LA" "tempPB" "")
      (command "_.explode" "L")
      
;;-+-----repeat each line of the edge     ;;;line segment iteration------------------------------------------------------------------------------------
      (repeat (setq m (sslength (setq sss (ssget "_P"))))
      
            (setq ent (ssname sss (setq m (1- m)))
                  lin_dst  (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) 
                  NumSpcs (1+ (fix(/ lin_dst maxSpcng)))
                  anchor_dist (/ lin_dst numspcs)
                  iX 1
            );end_setq

                (if (= 1 NumSpcs)             
                  (setq anchor_pt (vlax-curve-getpointatdist ent (* anchor_dist iX));;insertion - based on distance
                        anchor_obj (vlax-invoke c_spc 'insertblock anchor_pt blk 1 1 1 0);;inserting the block
                  )
                  (repeat NumSpcs
                    (setq anchor_pt (vlax-curve-getpointatdist ent (* anchor_dist iX));;insertion - based on distance
                          anchor_obj (vlax-invoke c_spc 'insertblock anchor_pt blk 1 1 1 0);;inserting the block
                          ix (+ iX 1)
                    ) 
                  )
                );;END IF
                
        (command "erase" ent "")       
      )
    ); repeat each edge ; repeat each line in exploded selection set--------------------------------------------------------------------------------
  ); if

(command "-purge" "la" "tempPB" "n") 
(command "._undo" "_end")
(princ)
); defun
 

 

This is what I'm trying to accomplish.

 

Offset-Stretch.thumb.png.82b6362f99aff0547c8a35c86263aa9c.pngDRW.dwg

Link to comment
Share on other sites

What may be simpler is offset pline and use a circle on each corner and trim. The circle rad = offset. Make circle then trim entlast and use vertice point. Erase circle.

 

 

image.png.1509645fa675f9e0ee5771d6f90611f2.png

 

Link to comment
Share on other sites

I thought there might be a simpler way to just stretch the end points instead of inserting circles or squares and then trimming.  Inserting might be the best way though.

Link to comment
Share on other sites

Try this has offset prefixed easy change to a user value. 

 

; trim using circle at corners
; By AlanH Juen 2022

(defun c:trimc ( / rad of pt co-ord)
(setq rad 0.2)

(setq plent (entsel "\nPick pline "))

(vla-offset (vlax-ename->vla-object (car plent)) rad)
(setq of (entlast))
(if of (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget of)))))

(foreach pt co-ord
(command "circle" pt rad)
(setq c (entlast))
(command "trim" c "" pt "")
(command "erase" c "")
)

(princ)
)

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...