Jump to content

Recommended Posts

  • 1 month later...
  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    15

  • gazzalp

    8

  • AustinTECH

    2

  • CAB

    1

Posted

I was wondering if anyone know how to combine these to lisp comands. One allows you to offset to both sides of a line and the other changes the line layer when you offset. Anyone have any ideas? What is a good way to learn how to creat lisp commands. Are there any books out there that anyone can suggest to read.

 

Thanks:)

 

 

(defun c:doff(/ oldDis plSet plLst delFlg)

(vl-load-com)

(if(not doffdis)(setq doffdis 10.0))

(setq oldDis doffdis

doffdis(getdist

(strcat "\nSpecify offset distance

(rtos doffdis

(getvar "LUNITS")

(getvar "LUPREC")) ">: "))

); end setq

(if

(not doffdis)

(setq doffdis oldDis)

); end setq

(if

(setq plSet

(ssget

'((0 . "LWPOLYLINE,LINE,ARC,CIRCLE,ELLIPSE,SPLINE"))))

(progn

(setq plLst

(mapcar 'vlax-ename->vla-object

(vl-remove-if 'listp

(mapcar 'cadr(ssnamex plSet)))))

(foreach pl plLst

(vla-Offset pl doffdis)

(vla-Offset pl(- doffdis))

); end foreach

(initget "Yes No")

(setq delFlg(getkword "\nDelete source objects [Yes/No]? : "))

(if(null delFlg)(setq delFlg "Yes"))

(if(= "Yes" delFlg)

(mapcar 'vla-Delete plLst)

); end if

); end progn

); end if

(princ)

); end of c:outline

(princ "\n*** Type DOFF for doubleside offset *** ")

 

 

_________________________________________________

 

 

(defun c:membrane (/ ent pt l1 l2)

(setq oldlay (getvar "clayer"))

(while (and

(setq ent (car (entsel "\nSelect object to offset 5 or :")))

(setq pt (getpoint "\nSpecify point on side to offset:"))

) ;_ end and

(if (not (tblsearch "Layer" "Membrane"))

(command "-layer" "m" "Membrane" "")

) ;_ end if

(command "._offset" 5.00 ent "_non" pt "")

(setq l1 (entlast))

(command "._offset" 10.00 ent "_non" pt "")

(setq l2 (entlast))

(command "_chprop" l1 "" "c" "cyan" "lt" "awthidden2" "la" "Membrane" "")

(command "_chprop" l2 "" "c" "red" "lt" "continuous" "la" "Membrane" "")

) ;_ end while

(setvar "clayer" oldlay)

(princ)

) ;_ end defun

Posted

Would you like to keep the same Layer changing properties as shown in the posted LISP?

 

i.e.

 

Line 1

Layer = "Membrane"

Linetype = "awthidden2"

Colour = Cyan

 

Line 2

Layer = "Membrane"

Linetype = "continuous"

Colour = Red

 

Or would you like to specify your own?

Posted

For example, something like this could be modified to suit your needs:

 

(defun c:doff (/ oldDis plSet plLst entlst1 entlst2 delFlg)
 (vl-load-com)
 (if (not doffdis) (setq doffdis 10.0))
 (setq    oldDis    doffdis
   doffdis    (getdist (strcat "\nSpecify offset distance <" (rtos doffdis
               (getvar "LUNITS")
               (getvar "LUPREC")) ">: ")))
 (if (not doffdis) (setq doffdis oldDis))
 (if (setq plSet (ssget '((0 . "LWPOLYLINE,LINE,ARC,CIRCLE,ELLIPSE,SPLINE"))))
    (progn
      (setq plLst (mapcar 'vlax-ename->vla-object
             (vl-remove-if 'listp
           (mapcar 'cadr (ssnamex plSet)))))
      (foreach    pl plLst
    (vla-Offset pl doffdis)
    (setq entlst1 (cons (vlax-ename->vla-object (entlast)) entlst1))
    (vla-Offset pl (- doffdis))
    (setq entlst2 (cons (vlax-ename->vla-object (entlast)) entlst2)))
      (foreach ent entlst1
    (vla-put-color ent "1"))
      (foreach ent entlst2
    (vla-put-color ent "2"))
      (initget "Yes No")
      (setq delFlg (getkword "\nDelete source objects [Yes/No]? <Yes>: "))
      (if (null delFlg) (setq delFlg "Yes"))
      (if (= "Yes" delFlg) (mapcar 'vla-Delete plLst))))
 (princ))
(princ "\n*** Type DOFF for doubleside offset *** ")

Posted

cool that works, it would be cool of it uses the layer you have set current.

Posted

This puts the new lines on the current layer:

 

(defun c:doff (/ oldDis plSet plLst entlst1 entlst2 delFlg)
 (vl-load-com)
 (if (not doffdis) (setq doffdis 10.0))
 (setq    oldDis    doffdis
   doffdis    (getdist (strcat "\nSpecify offset distance <" (rtos doffdis
               (getvar "LUNITS")
               (getvar "LUPREC")) ">: ")))
 (if (not doffdis) (setq doffdis oldDis))
 (if (setq plSet (ssget '((0 . "LWPOLYLINE,LINE,ARC,CIRCLE,ELLIPSE,SPLINE"))))
    (progn
      (setq plLst (mapcar 'vlax-ename->vla-object
             (vl-remove-if 'listp
           (mapcar 'cadr (ssnamex plSet)))))
      (foreach    pl plLst
    (vla-Offset pl doffdis)
    (setq entlst1 (cons (vlax-ename->vla-object (entlast)) entlst1))
    (vla-Offset pl (- doffdis))
    (setq entlst2 (cons (vlax-ename->vla-object (entlast)) entlst2)))
      (mapcar '(lambda (x) (vla-put-color x 1)
                     (vla-put-layer x (getvar "clayer"))) entlst1)
      (mapcar '(lambda (x) (vla-put-color x 2)
                     (vla-put-layer x (getvar "clayer"))) entlst2)
      (initget "Yes No")
      (setq delFlg (getkword "\nDelete source objects [Yes/No]? <Yes>: "))
      (if (null delFlg) (setq delFlg "Yes"))
      (if (= "Yes" delFlg) (mapcar 'vla-Delete plLst))))
 (princ))
(princ "\n*** Type DOFF for doubleside offset *** ")

 

 

Let me know if you want the colours changed. :thumbsup:

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