Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Resurrected Double Offset Lisp

  1. #1
    Login to Give a bone
    0

    Default Resurrected Double Offset Lisp

    So I googled around today for a double offset command, and found the code at this AUGI link:

    http://forums.augi.com/showthread.ph...le-Line-Offset

    Code:
    (defun C:OL (/ lstSelection objSelection sngDistance)
     (while (and (not (setq lstSelection (entsel "\nSelect object to offset: ")))
                 (/= (getvar "ErrNo") 52)
            )
      (princ "\nNull Selection please try again: ")
     )
     (if lstSelection
      (progn
       (setq objSelection (vlax-ename->vla-object (car lstSelection))
             sngDistance  (getdist "\nEnter offset distance: ") 
       )
       (vla-offset objSelection sngDistance)
       (vla-offset objSelection (- sngDistance))
       (if (not (tblsearch "ltype" "center"))
        (vla-load (vla-get-linetypes 
                   (vla-get-activedocument 
                    (vlax-get-acad-object)
                   )
                  )
                  "center"
                  "ACAD.LIN"
        )
       )
       (vla-put-linetype objSelection "center")
      )
     )
     (prin1)
    )
    It works great with all basic autocad objects that I've tested against so far, but there's two additions I'd like to make, but have no clue how to go about it.

    1. I would like the offset distance to be remembered, such as it does with the normal offset command (just hit enter when asked for the distance to accept the previous value)
    2. Ask if I would like to keep the selected line or not (Y=yes to keep, N=no to delete)

    Can anyone help me add these options?
    Last edited by g.johnston222936339; 2012-10-23 at 02:50 PM. Reason: added source

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    Is the code you posted above what you found somewhere not mentioned on the interwebs, or your adaptation of?

    You didn't attribute the original author, so we have no way of knowing the original author's terms.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    Quote Originally Posted by RenderMan View Post
    You didn't attribute the original author, so we have no way of knowing the original author's terms.
    Fair enough

  4. #4
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    An similar code. I let it you to translate prompt commande.

    Code:
    (vl-load-com)
    (defun c:dbl_offset ( / val_offset del_ent js ent vla_obj)
      (initget 6)
      (setq val_offset (getdist (strcat "\nLargeur totale du décalage <" (rtos (getvar "USERR1")) ">:")))
      (if (not val_offset) (setq val_offset (getvar "USERR1")) (setvar "USERR1" val_offset))
      (initget "Oui Non _Yes No")
      (setq del_ent (if (eq (getkword "\nSupprimer l'entité sélectionnée [Oui/Non] <Non>: ") "Yes") T nil))
      (while (/= ent "Exit")
        (setq js (ssadd))
        (initget "Sortir _Exit")
        (while (or (null (setq ent (entsel "\nChoix de l'objet à décaler de part et d'autre/[Sortir]: "))) (/= ent "Exit"))
          (cond
            ((not (null ent))
              (setq ent (car ent))
              (setq vla_obj (vlax-ename->vla-object ent))
              (vla-Offset vla_obj (/ val_offset 2.0))
              (setq js (ssadd (entlast) js))
              (vla-Offset vla_obj (- (/ val_offset 2.0)))
              (setq js (ssadd (entlast) js))
              (if del_ent (entdel ent))
            )
          )
          (initget "Sortir _Exit")
        )
        (if js (sssetfirst nil js))
      )
      (princ)
    )

  5. #5
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    Quote Originally Posted by pbejse View Post
    Quote Originally Posted by RenderMan View Post
    Is the code you posted above what you found somewhere not mentioned on the interwebs, or your adaptation of?

    You didn't attribute the original author, so we have no way of knowing the original author's terms.
    Fair enough
    Yes, definately fair enough. I've added the link to where I found the code (all credit goes to Peter Jamtgaard for the code, and some to RobertB for the suggestions that Peter incorporated into the code I've got listed.)

    I don't see any "terms" that either of them have listed, and I'm in no way going to turn around and attempt to profit from this (other than expediting my work slightly, but we all strive to do that).

    Thanks in advance

    GJ

  6. #6
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    double post, thread wasn't updating for some reason

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    Quote Originally Posted by g.johnston222936339 View Post
    Yes, definately fair enough. I've added the link to where I found the code (all credit goes to Peter Jamtgaard for the code, and some to RobertB for the suggestions that Peter incorporated into the code I've got listed.)

    I don't see any "terms" that either of them have listed, and I'm in no way going to turn around and attempt to profit from this (other than expediting my work slightly, but we all strive to do that).

    Thanks in advance

    GJ
    No worries; most authors that post code are fine with public consumption, unless any sort of 'terms' has been added.

    That was your first post here, so I just wanted to point you in the right direction with regard to accrediting others where reasonable. There are times, the original author is unknown... These things happen.

    We'd certainly be able to help you, regardless... I'm a bit swamped at the moment, but I'll check back later to see if I can be of help.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #8
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    I swear I've posted here before, but when I tried to log in, it told me my email wasn't registered.... maybe i used a different one and have forgotten LOL.

    Otherwise, yea... I don't post often, but I do browse here often enough (and on other forums) to know that I should have given credit where credit is due. And in advance to anyone that helps, Thanks much, help is very much appreciated

  9. #9
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    Quote Originally Posted by g.johnston222936339 View Post
    ... there's two additions I'd like to make, but have no clue how to go about it.

    1. I would like the offset distance to be remembered, such as it does with the normal offset command (just hit enter when asked for the distance to accept the previous value)
    2. Ask if I would like to keep the selected line or not (Y=yes to keep, N=no to delete)

    Can anyone help me add these options?
    When dealing with settings there's two general directions one can go... Temporary or Persistent settings.

    The former would generally be considered 'global variables' in LISP, and only exist within the drawing that they were given a value.

    The latter allow for your settings to exist beyond closing of a given Document. This can be done either by internally saving to the Document via Dictionary, or XRecord, Custom Property, etc. (which may not be accessible to other Documents), or by storing to an external location, such as to File, or most commonly to Registry.

    For the purposes of this example, we'll save to a simple pair of global variables... Written quickly, I believe that this will get you started:

    Code:
    (vl-load-com)
    
    (defun c:OF+ () (c:OffsetPlus))
    (defun c:OffsetPlus (/ *error* _OffsetPlus:Settings _OffsetPlus:Distance
                         sel dist v acDoc
                        )
    
      (defun *error* (msg)
        (if acDoc
          (vla-endundomark acDoc)
        )
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (defun _OffsetPlus:Settings (/ erase)    
        (initget "No Yes")
        (or (setq erase
                   (getkword
                     (strcat "\nErase selection [No/Yes]"
                             (if *OffsetPlus_Erase*
                               " <Yes>: "
                               ": "
                             )
                     )
                   )
            )
            (setq erase *OffsetPlus_Erase*)
        )
        (setq *OffsetPlus_Erase*
               (if (= "No" erase)
                 nil
                 T
               )
        )
        (c:OffsetPlus)
      )
    
      (defun _OffsetPlus:Distance (sel / dist)
        (not (initget (+ 32 128)))
        (or (setq dist
                   (getdist
                     (cadr sel)
                     (strcat "\nSpecify offset distance"
                             (if *OffsetPlus_Distance*
                               (strcat " <" (rtos *OffsetPlus_Distance*) ">: ")
                               ": "
                             )
                     )
                   )
            )
            (setq dist *OffsetPlus_Distance*)
        )
        (setq *OffsetPlus_Distance* dist)
      )
    
      (if
        (and
          (or
            (setq sel
                   (entsel "\nSelect object to offset, <Enter> for Settings: "
                   )
            )
            (_OffsetPlus:Settings)
          )
          (_OffsetPlus:Distance sel)
          (setq v (vlax-ename->vla-object (car sel)))
        )
         (progn
           (vla-startundomark
             (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
           )
           (foreach d (list (abs *OffsetPlus_Distance*)
                            (* -1.0 *OffsetPlus_Distance*)
                      )
             (vla-offset v d)
           )
           (if *OffsetPlus_Erase*
             (vla-delete v)
             (progn
               (if (not (tblsearch "ltype" "center"))
                 (vla-load (vla-get-linetypes acDoc) "center" "ACAD.LIN")
               )
               (vla-put-linetype v "center")
             )
           )
         )
      )
      (*error* nil)
    )

    ** Edit to add - I've also included 'undo' functionality, FWIW.

    HTH
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  10. #10
    Login to Give a bone
    0

    Default Re: Resurrected Double Offset Lisp

    ok, so I'm not getting it to work... I get:

    Command: oi
    ; error: no function definition: C:OFFSETPLUS

    I've changed the second line to read:

    (defun ci () (c:OffsetPlus))

    with the idea that OF+ is too many keystrokes and too far across the keyboard and back (I'm one of those left hand only CAD'ers, until I have to start typing large amounts of text).

    Any more thoughts?

Page 1 of 2 12 LastLast

Similar Threads

  1. Double Line Offset
    By BCrouse in forum AutoLISP
    Replies: 11
    Last Post: 2015-09-10, 08:59 PM
  2. offset lisp?
    By jdcincy in forum AutoLISP
    Replies: 24
    Last Post: 2014-05-14, 06:30 PM
  3. TOP CHORD OFFSET DOUBLE PITCHED UNDERSLUNG DLH JOIST
    By T.WADE in forum Revit Structure - General
    Replies: 0
    Last Post: 2010-01-05, 03:40 PM
  4. Double Offset
    By vipin_nair in forum AutoLISP
    Replies: 2
    Last Post: 2008-02-22, 09:06 AM
  5. Double offset?
    By darkknightsac in forum AutoCAD Customization
    Replies: 4
    Last Post: 2005-10-18, 06:49 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •