Jump to content
CafeJr

Multiple Offset, how to fix it?

Recommended Posts

CafeJr

Guys,

 

I got this code, to do a multiple offset, it works good, but I need to do one complementation in that, the direction of final objects, the code doesn't allow you choose it, every time the code draw the offset line above of objects, It's possible fix it? Indicating the direction of end offset lines...

 

Thanks in advance...

 

(defun c:mo (/ plines ; selection set of polylines
      ext ; extrnal point
      dist ; distance to offset
      poly ; a polyline from plines
      plist ; the list of poly
      del ; polyline to delete
      int ; internal point
      i
      layer)  
 (command "undo" "begin")
 (princ "select polylines")
 (setq plines (ssget)
i      0
ext    (getvar "limmax")
dist   (getdist "distance = ")
 )
 (repeat (sslength plines)
   (setq poly (ssname plines i))
   (setq plist (entget poly))
   (command "offset" dist poly ext "")
   ;(setq del (entlast)
   ;int (polar
   ;(cdr (assoc 10 (entget del)))
   ;(angle
   ;(cdr (assoc 10 (entget del)))
   ;(cdr (assoc 10 plist)))
   ;(* 2 (distance (cdr (assoc 10 plist))
   ;(cdr (assoc 10 (entget del)))))))
   ;(command "offset" dist poly int "")
   ;(entdel del)
   (setq i (1+ i))
 )
 (command "undo" "end")
 (if (= "Y"
 (strcase (getstring "\ndelete initial polylines? (Y/N) = "))
     )
   (command "erase" plines "")
 )
)

Share this post


Link to post
Share on other sites
CheSyn

Untested, but should fix the issue. I changed "ext" (added getpoint) and "dist" (added \n)

 

(defun c:mo (/ plines ; selection set of polylines
      ext ; extrnal point
      dist ; distance to offset
      poly ; a polyline from plines
      plist ; the list of poly
      del ; polyline to delete
      int ; internal point
      i
      layer)  
 (command "undo" "begin")
 (princ "select polylines")
 (setq plines (ssget)
i      0
ext    (getpoint "\nSelect the offset direction")
dist   (getdist "\ndistance = ")
 )
 (repeat (sslength plines)
   (setq poly (ssname plines i))
   (setq plist (entget poly))
   (command "offset" dist poly ext "")
   ;(setq del (entlast)
   ;int (polar
   ;(cdr (assoc 10 (entget del)))
   ;(angle
   ;(cdr (assoc 10 (entget del)))
   ;(cdr (assoc 10 plist)))
   ;(* 2 (distance (cdr (assoc 10 plist))
   ;(cdr (assoc 10 (entget del)))))))
   ;(command "offset" dist poly int "")
   ;(entdel del)
   (setq i (1+ i))
 )
 (command "undo" "end")
 (if (= "Y"
 (strcase (getstring "\ndelete initial polylines? (Y/N) = "))
     )
   (command "erase" plines "")
 )
)

Share this post


Link to post
Share on other sites
CafeJr
Untested, but should fix the issue. I changed "ext" (added getpoint) and "dist" (added \n)

 

Tested!... Thanks CheSyn!... Works well!!!...

Share this post


Link to post
Share on other sites
the lagman

HI to all!

Is there a way to add to the above code the ability to change the layer also of the offset objects??

Thanks in advance!

Share this post


Link to post
Share on other sites
MSasu

To change the layer of newly created polylines (adjust part in blue to suit your case):

...
   (setq plist (entget poly))
   (command "offset" dist poly ext "")
   [color=magenta](command "_CHPROP" (entlast) "" "_LA" "[color=blue]NameOfTargetLayer[/color]" "")[/color]
...

Share this post


Link to post
Share on other sites
the lagman
To change the layer of newly created polylines (adjust part in blue to suit your case):

...
   (setq plist (entget poly))
   (command "offset" dist poly ext "")
   [color=magenta](command "_CHPROP" (entlast) "" "_LA" "[color=blue]NameOfTargetLayer[/color]" "")[/color]
...

 

Wow thank you so much! Really appreciate your help! Works exactly as needed!

Share this post


Link to post
Share on other sites
MSasu

You're entirely welcome!

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...