See the top rated post in this thread. Click here

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Sample AutoLISP code - what would you do different?

  1. #11
    Active Member David.Hoole's Avatar
    Join Date
    2000-12
    Location
    Yorkshire
    Posts
    84
    Login to Give a bone
    0

    Default Re: Sample AutoLISP code - what would you do different?

    Robert

    How about the SETCFG & GETCFG functions? I still use these to store preferred printer device names on networked CAD stations.

  2. #12
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Sample AutoLISP code - what would you do different?

    Ah yes, I had forgotten about those, in my old age.

  3. #13
    Member
    Join Date
    2000-12
    Posts
    10
    Login to Give a bone
    0

    Default Re: Sample AutoLISP code - what would you do different?

    Here is a niffy offset routine... ex: on current layer - offset a line from another layer and make it reside on current layer code: Got this from a freeware site

    ;Offset -- Improved offset command (offsets to current layer)

    (defun C:OO ( / Ent1 list1 )
    (setvar "cmdecho" 1)
    (setvar "aunits" 4)
    (setvar "unitmode" 0)
    (setvar "PLINEGEN" 0)
    (setvar "maxsort" 2000)
    (setvar "trimmode" 1)
    (setvar "projmode" 1)
    (setq list1 "")
    (setq Ent1 (getvar "offsetdist"))
    (command ".OFFSET")
    (while (< 0 (getvar "CMDACTIVE"))
    (command pause)
    (if (not (equal ent1 (entlast))) (progn
    (setq ent1 (entlast))
    (setq list1 (entget ent1))
    (setq list1 (subst
    (cons 8 (getvar "CLAYER")) (assoc 8 list1) list1))
    (entmod list1)
    )))
    (princ)
    )

    (if C:Offset
    (command "UNDEFINE" "OFFSET"))
    (princ)

  4. #14
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    1

    Smile Re: Sample AutoLISP code - what would you do different?

    Richard,
    Nice Job. Very clever the way you preserved the use of Through.
    Here are my revisions to your routine.
    Code:
    (defun c:ofs (/ usrcmd prm dist e p clayer)
      (setq usrcmd (getvar "cmdecho"))
      (setvar "cmdecho" 0)
      (setq clayer (getvar "clayer"))
      (princ "\nOffset Object\n")
      ;; if first time through set to default value 
      (if (null *zyz_off*)(setq *zyz_off* 2))
      (if (= 'real (type *zyz_off*))
        (setq dist (rtos *zyz_off*))
        (setq dist *zyz_off*)
      )
      (initget 68 "Through")
      (setq dist (getdist
                   (strcat "Distance to offset or Through <"
                            dist ">:")))
      ;; Pressing ENTER uses the previous value
      (if (null dist) (setq dist *zyz_off*))
      (if (= 'real (type dist))
        (setq prm "\nSelect side to offset:")
        (setq prm "\nSelect through point:")
      )
      (setq *zyz_off* dist)
      (while (setq e (entsel "\nSelect entity to offset:"))
        (redraw (car e) 3)
        (if (setq p (getpoint prm))
          (command "_.offset" *zyz_off* e p ""
                   "CHANGE" "L" "" "P" "LA" Clayer ""))
      )
      (setvar "cmdecho" usrcmd)
      (princ)
    ); defun

Page 2 of 2 FirstFirst 12

Similar Threads

  1. .Net TRANSMITTALLib Sample Code
    By bernie.snodgrass892799 in forum Dot Net API
    Replies: 6
    Last Post: 2014-01-06, 03:10 PM
  2. Error in a sample code ?
    By Dubweisertm in forum Dot Net API
    Replies: 3
    Last Post: 2011-09-08, 08:17 PM
  3. Sample code Error
    By r.vetrano in forum Revit - API
    Replies: 2
    Last Post: 2007-07-09, 11:42 AM
  4. Replies: 0
    Last Post: 2006-04-10, 05:38 PM

Posting Permissions

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