Jump to content

A different kind of the offset command


jcap91163

Recommended Posts

Good day to all of you, my question is as follows:

Is there any form to offset a line from a base, but one line in any given distance and the other in another given distance?

Thank you very much in advance for your help.

Link to comment
Share on other sites

Not too difficult to code. You could create as many offsets and as many different distance as you like.

 

Here's the prompt for a simple one I wrote to perform the offsets for curb and gutter.

 

Command: om
1: 0.5' Curb
2: 8" Extruded Curb
3: 0.5' Curb & 1' Gutter (From Back of Curb)
4: 0.5' Curb & 1.5' Gutter (From Back of Curb)
5: 0.5' Curb & 1' Gutter (From Lip of Curb)
6: 0.5' Curb & 1.5' Gutter (From Lip of Curb)
Offset choice [1/2/3/4/5/6] <3>:

 

It just offsets the first distance, then offsets the second distance. Nothing special or complicated.

Link to comment
Share on other sites

thank you very much for your quick response, unfortunately I had no skills in writing lisp codes so, I'm lost with your codes, perhaps an example much be easier for me to read.

Thank you very much again.

Link to comment
Share on other sites

I didn't post any code. I just posted the commandline prompt as an example. It wouldn't be difficult to code, but you'd have know your distance parameters for each 'offset'.

Link to comment
Share on other sites

Further to Alanjt I wrote a multi offset as many as you liked it just asked for the offset distance and kept asking till you gave a blank answer it would then repeat the offset command for this list of offsets.

 

Alanjt has suggested that an offset command is pretty easy in lisp but you hard code what you want as an answer for the offset distance.

 

Written on the fly

(setq obj (entsel))

(setq pt1 (getpoint "\pick side to offset"))

(command "Offset" 5.0 obj pt1 "")

(command "Offset" 10.0 obj pt1 "")

 

If you want to vary the offset then just add more code to ask for offset value and replace in code.

Link to comment
Share on other sites

Quickie and I might use this myself...

 

 

(defun c:CO (/ ent pt dist)
 ;; Continuous Offset
 ;; Required Subroutines: AT:Entsel
 ;; Alan J. Thompson, 08.03.10
 (if (and (setq ent (AT:Entsel nil
                               "\nSelect object to offset: "
                               '("L" (0 . "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE"))
                               nil
                    )
          )
          (setq pt (getpoint "\nSpecify point on side to offset: "))
     )
   ((lambda (d)
      (while (/= dist "Exit")
        (initget 6 "Exit")
        (if (numberp (setq dist (cond ((getreal (strcat "\nSpecify offset distance [Exit]"
                                                        (if (numberp dist)
                                                          (strcat " <" (rtos dist) ">: ")
                                                          ": "
                                                        )
                                                )
                                       )
                                      )
                                      (dist)
                                )
                     )
            )
          (command "_.offset" (setq d (+ d dist)) ent "_non" pt "")
        )
      )
    )
     0.
   )
 )
 (princ)
)





(defun AT:Entsel (nest msg flt kwrd / vlaLck flt _match ent good)
 ;; nest - Entsel or NEntselP (T for NEntselP, nil for Entsel)
 ;; msg  - Display message (if nil, "\nSelect object: " is used)
 ;; flt  - Filter list (DXF SSGet style filter or a lambda express to match) nil if not required
 ;;                   "V" as first item in list to convert object to VLA-Object
 ;;                   "L" as first item in list to ignore locked layers
 ;; kwrd - Kewords to match instead of object selection (nil if not required)
 ;; Example: (AT:Entsel nil "\nSelect line [settings]: " '("LV" (0 . "LINE")(8 . "~0")) "Settings")
 ;; Example: (AT:Entsel nil nil (list "V" (lambda (x) (eq "TEXT" (cdr (assoc 0 (entget (car x))))))) nil)
 ;; Copyright© Alan J. Thompson, 04.16.09
 ;; Updated: Alan J. Thompson, 06.04.09 (changed filter coding to work as ssget style dxf filtering)
 ;; Updated: Alan J. Thompson, 09.07.09 (added option to ignore locked layers and convert object to VLA-OBJECT
 ;; Updated: Alan J. Thompson, 09.18.09 (fixed 'missed pick' alert)
 ;; Updated: Alan J. Thompson, 06.03.10 (complete rewrite and added option to apply lambda function to selection)
 (setvar 'errno 0)
 ;; if available, sort out filters (flt) to see what applies
 (if (vl-consp flt)
   (progn
     ;; first item string (ignore locked layers, convert to vla-object)
     (and (eq (type (car flt)) 'STR)
          (setq vlaLck (car flt)
                flt    (cdr flt)
          )
     )
     ;; flt equal to DXF list
     (cond ((vl-consp (car flt))
            (setq _match (lambda (x)
                           (not
                             (vl-position
                               nil
                               (mapcar
                                 (function
                                   (lambda (f)
                                     (wcmatch
                                       (strcase
                                         (vl-princ-to-string
                                           (cdr (assoc (car f) (entget (car ent))))
                                         )
                                       )
                                       (strcase (vl-princ-to-string (cdr f)))
                                     )
                                   )
                                 )
                                 flt
                               )
                             )
                           )
                         )
            )
           )
           ;; flt equal to function
           ((eq (type (car flt)) 'SUBR) (setq _match (car flt)))
     )
   )
 )
 (while (not good)
   (and kwrd (initget 0 kwrd))
   (setq ent ((cond (nest nentselp)
                    (entsel)
              )
               (cond (msg)
                     ("\nSelect object: ")
               )
             )
   )
   (cond
     ((vl-consp ent)
      ;; ignore locked
      (and
        (eq (type vlaLck) 'STR)
        (wcmatch (strcase vlaLck) "*L*")
        (eq 4
            (logand 4
                    (cdr
                      (assoc 70 (entget (tblobjname "LAYER" (cdr (assoc 8 (entget (car ent)))))))
                    )
            )
        )
        (setq good (setq ent (prompt "\nObject on locked layer!")))
      )
      ;; DXF list to match or function
      (and (vl-consp ent)
           _match
           (or (_match ent) (setq good (setq ent (prompt "\nInvalid object!"))))
      )
      ;; convert to vla-object
      (if (and (vl-consp ent) (eq (type vlaLck) 'STR) (wcmatch (strcase vlaLck) "*V*"))
        (setq good (vlax-ename->vla-object (car ent)))
        (setq good ent)
      )
     )
     ((eq (type ent) 'STR) (setq good ent))
     ((setq good (eq 52 (getvar 'errno))) nil)
     ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again.")))
   )
 )
)

Link to comment
Share on other sites

alantj, many thanks, works very fine and is what I was looking for.

one more thing, is there any way to select also the other side of the main line, say, pick one side and asign as many offsets that I want, and then pick the other side and have also many distances?

thanks in advance and sorry for taking to much of your time.

Link to comment
Share on other sites

Quickie...

 

(defun c:CO (/ ent pt dist)
 ;; Continuous Offset
 ;; Required Subroutines: AT:Entsel
 ;; Alan J. Thompson, 08.03.10
 (if (and (setq ent (AT:Entsel nil
                               "\nSelect object to offset: "
                               '("L" (0 . "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE"))
                               nil
                    )
          )
          (setq pt (initget 0 "Both")
                pt (getpoint "\nSpecify point on side to offset or [both]: ")
          )
     )
   ((lambda (d)
      (if (eq pt "Both")
        (setq ent (vlax-ename->vla-object (car ent)))
      )
      (while (/= dist "Exit")
        (initget 6 "Exit")
        (if (numberp (setq dist (cond ((getreal (strcat "\nSpecify offset distance [Exit]"
                                                        (if (numberp dist)
                                                          (strcat " <" (rtos dist) ">: ")
                                                          ": "
                                                        )
                                                )
                                       )
                                      )
                                      (dist)
                                )
                     )
            )
          (if (eq pt "Both")
            (mapcar (function (lambda (n) (vl-catch-all-apply (function vla-offset) (list ent n))))
                    (list (setq d (+ d dist)) (- d))
            )
            (command "_.offset" (setq d (+ d dist)) ent "_non" pt "")
          )
        )
      )
    )
     0.
   )
 )
 (princ)
)

Link to comment
Share on other sites

Thank you very much for your time and your great work.
You're welcome. I have a continuous copy one and I've actually been wanting to writing a continuous offset one. Enjoy. :)
Link to comment
Share on other sites

Hi alanjt,

 

I loaded your code, but it only work first time, after sometime it doesn't work anymore. Does the code expires?

 

Thanks

Link to comment
Share on other sites

Hi alanjt,

 

I loaded your code, but it only work first time, after sometime it doesn't work anymore. Does the code expires?

 

Thanks

That doesn't make any sense. The code should function fine. You'll have to give me a little more information as to what's happening.
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...