Jump to content

Autocad 2008 Offset command


Recommended Posts

Posted

Hello, is there any way that you can set the layer attributes to something other than the item that you are offsetting? For example I have a line on a BLDG layer in Color red but I want to offset that line to be in the GYPSUM layer with a color #8 (Grey) attribute.

 

This would really be helpful for I use Autocad for designing homes.

 

Thank you

 

Raff

 

P.S. I looked but never found any threads similar

Posted

Set your destination layer current.

Run the Offset command, press L, press C, continue the offset command.

Posted

You are awesome. Thank you very much, from the whole office LOL.

Posted

There are some lisp routines out there but it really is easier to set the layer current and offset.

 

Actually you could write a pretty simple lisp to define OG as offset to gypboard layer, etc., where it would change the layer prior to launching the offset command. Or a simple macro for a toolpalette, etc.

Posted

Oh is therre a way to set a button to this or does it have to be done this way every time?

 

It will work if I change to a different layer but what if I wanted same layer but different color?

 

I have a BLDG layer with color white and trying to offset it to a color blue and not working.

Posted

Yeah, I think a lisp routine would be required. I am not much on lisp but I know it can be done.

At the start of the routine the layer would be created or set, the distance could be built in, like 1/2" or 5/8" for the gypboard example, offset would be called, you would point to the side, then the last entity would be changed to the current layer. Maybe ask over in the customization forum.

Posted

This is one I cobbled together, you would have to keep customizing it for the layers, colors and distances you would want preset. There are much more elegant solutions but this works.

 

 

(DeFun C:OFFM ( / clayer  ENTITY) ; change OFFM to any name you like that doesn't already exist

(SetVar "CmdEcho" 0)

(INITGET "G g S s B b U u") ; add a unique letter for each material you add
 (SETQ MatType (strcase (getkword "\nGypboard  Stud  Brick  stUcco..? ")))
 (COND
((= MatType "B") ;set this letter to match one of the choices three lines above, B = brick
 (SETQ layernam  "BRICK") ;change BRICK to a layer name you would use, repeat for those below
 (SETQ offsetdista "2.5")  ;change to offset distance for brick, repeat for those below
 (SETQ layercolor "1")  ;set color to what you would want, repeat for those below
)
     ((= MatType "G")
 (SETQ layernam  "GYPSUM")
 (SETQ offsetdista "5/8")
 (SETQ layercolor "4")
)

((= MatType "S")
 (SETQ layernam  "STUD")
 (SETQ offsetdista "3.5")
 (SETQ layercolor "2")
)
((= MatType "U")
 (SETQ layernam  "STUCCO")
 (SETQ offsetdista "1")
 (SETQ layercolor "3")
)
 );close cond
(COMMAND ".LAYER" "make" LAYERNAM "color" layercolor "" "")
(Command ".OFFSET" offsetdista pause pause "")
 (SetQ ENTITY (EntLast) 
       ENTITY (EntGet ENTITY)
       ENTITY (SubSt (Cons 8 layernam) (Assoc 8 ENTITY) ENTITY)
 )
 (EntMod ENTITY)
(SetVar "CmdEcho" ECHO)

 (PrinC)
)

Posted

Here's one which uses the current settings for Layer, Colour, Linetype, Lineweight and Object Linetype Scale. Command is OffsetCurrent

(vl-load-com)
;;; Parse a string to a list of strings splitting at delimeter
;;; From: http://thatcadguy.blogspot.com/2009/10/parsing-csv-files-with-autolisp.html
(defun str2lst (strg delim trim / templist pos)
 (if trim
   (setq strg (vl-string-trim delim strg))
 )
 (setq templist (list))
 (while (setq pos (vl-string-search delim strg))
   (setq templist (cons (substr strg 1 pos) templist)
         strg     (substr strg (+ 2 pos))
   )
 )
 (reverse (cons strg templist))
)

;;; Command to offset to current layer / color / linetype / lineweight / linetypescale
(defun c:OffsetCurrent (/ elast Run)
 ;; Helper function to modify the last object
 (defun Run (en / eo color)
   (setq eo (vlax-ename->vla-object en))
   (vla-put-Layer eo (getvar "CLAYER"))
   (setq color (strcase (getvar "CECOLOR")))
   (cond
     ((wcmatch color "RGB:*")
       (setq color (str2lst (substr color 5) "," t))
       (setq eco (vla-get-TrueColor eo))
       (vla-SetRGB eco (atoi (car color)) (atoi (cadr color)) (atoi (caddr color)))
       (vla-put-TrueColor eo eco)
     )
     ((wcmatch color "BYLAYER") (vla-put-Color eo 256))
     ((wcmatch color "BYBLOCK") (vla-put-Color eo 0))
     (t (vla-put-Color eo (atoi color)))
   )
   (vla-put-LineType eo (getvar "CELTYPE"))
   (vla-put-Lineweight eo (getvar "CELWEIGHT"))
   (vla-put-LinetypeScale eo (getvar "CELTSCALE"))
 )

 ;; Run the offset command until the user completes
 (setq elast (entlast))
 (command "._OFFSET")
 (while (= (logand (getvar "CMDACTIVE") 1) 1)
   (if (not (eq elast (entlast)))
     (Run (setq elast (entlast)))
   )
   (command pause)
 )

 (princ)
)

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