Jump to content

offset to layer


michaeloureiro

Recommended Posts

Hey all,

 

does anybody know of lisp that can offset to the current layer, or layer of choice?

 

thanks in advance!

I believe the OFFSET command already does this.

 

Command: offset

Specify offset distance or [Through/Erase/Layer]

Link to comment
Share on other sites

YEP, and here's one from another thread:

 

;Offset to current layer...excellent program.
(DeFun C:OSET1 (/ LAYER ECHO TEMP 
 ENTITY)
(SetQ LAYER (GetVar "CLayer")
       ECHO (GetVar "CmdEcho"))
(SetVar "CmdEcho" 0)
(While 
 (ProgN
  (SetQ TEMP (GetString (StrCat 
   "\nDestination layer? <"LAYER">:")))
  (Cond
   ((Eq TEMP "") Nil)
   ((TblSearch "LAYER" TEMP) (SetQ 
    LAYER TEMP) Nil)
   (T (PrinC "\nLayer not found."))
)))
(InitGet (+ 2 4) "Through")
(SetQ TEMP (GetDist (StrCat
 "\nOffset distance or Through <"
 (If DIST (RToS DIST) "Through")
 ">: ")))
(Cond
 ((Eq TEMP "Through") (SetQ DIST Nil))
 (TEMP (SetQ DIST TEMP))
)
(SetQ TEMP (If DIST "\nSide to offset?" 
 "\nThrough point: "))
(While
 (And
  (SetQ ENTITY (EntSel 
   "\nSelect object to offset: "))
  (SetQ PT (GetPoint TEMP))
 )
 (Command ".OFFSET" (If DIST DIST "T") 
  ENTITY PT "")
 (SetQ ENTITY (EntLast) 
       ENTITY (EntGet ENTITY)
       ENTITY (SubSt (Cons 8 LAYER) 
           (Assoc 8 ENTITY) ENTITY))
 (EntMod ENTITY)
)
(SetVar "CmdEcho" ECHO)
(PrinC)
)

Link to comment
Share on other sites

  • 4 years later...
Is there a way to offset an object to the source layer, but change the original object to a different layer, all in the same motion?

 

Is this at all possible?

 

I like the code that GhostRider suggest and I've been tweaking it to attempt these results, but I'm no programmer, so it's not surprising I've had no luck.

Link to comment
Share on other sites

Here is a very simple example:

(defun c:myoffset ( / ent off )
   (if
       (and
           (setq ent (car (entsel "\nSelect object to offset: ")))
           (setq off (getdist "\nSpecify offset distance: "))
       )
       (if (vl-cmdf "_.offset" "_L" "_S" off ent "\\" "")
           (entmod (subst '(8 . "YourLayerHere") (assoc 8 (setq ent (entget ent))) ent))
       )
   )
   (princ)
)

Link to comment
Share on other sites

Here is a very simple example:

(defun c:myoffset ( / ent off )
(if
(and
(setq ent (car (entsel "\nSelect object to offset: ")))
(setq off (getdist "\nSpecify offset distance: "))
)
(if (vl-cmdf "_.offset" "_L" "_S" off ent "\\" "")
(entmod (subst '(8 . "YourLayerHere") (assoc 8 (setq ent (entget ent))) ent))
)
)
(princ)
)

 

Excellent! Worked perfectly!

 

Thank you Lee Mac!

Link to comment
Share on other sites

Excellent! Worked perfectly!

 

Thank you Lee Mac!

 

You're welcome!

 

can be pick object to get its layer and set it for offset layer

 

Here is a very simple program, assuming I have understood your intention:

(defun c:myoffset ( / ent lay old )
   (if (setq ent (car (entsel "\nPick object for offset layer: ")))
       (progn
           (setq lay (cdr (assoc 8 (entget ent)))
                 old (getvar 'clayer)
           )
           (vl-cmdf "_.-layer" "_T" lay "_S" lay "" "_.offset" "_L" "_C")
           (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "\\"))
           (setvar 'clayer old)
       )
   )
   (princ)
)

Link to comment
Share on other sites

thanks

lee for reply but what i mean is the same lisp you have wrot it befor but instead of typing layer in the code to pick known object for me and get its layer and make the offset object move to the same layer of object i have picked

sequence of commands

pick object for offset

-enter offset value

-pick object to get its layer

loop here

-offset done to the picked layer

Link to comment
Share on other sites

thanks

lee for reply but what i mean is the same lisp you have wrot it befor but instead of typing layer in the code to pick known object for me and get its layer and make the offset object move to the same layer of object i have picked

 

Just use the OFFSET > LAYER > SOURCE option of the offset command?

Link to comment
Share on other sites

Excellent! Worked perfectly!

 

Thank you Lee Mac!

 

I do have a tweak if possible, can you change it to prompt the offset first, then the object?

And maintain the ability to choose additional objects after offsetting the first? Similar to the natural function of the offset command.

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