Author Topic: offset lisp problem  (Read 4553 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 297
offset lisp problem
« on: June 04, 2012, 10:06:52 PM »
i made  offset to new layer lisp
but that didnot work well
what problem ?

Code: [Select]
(defun c:qa (    )
(setq off_lay2 (getvar "clayer"))

(command "-Layer" "m" "_temp-offset"  "c" "140" "_temp-offset" "")

(setq off_lay "_temp-offset")

(if ( not e-hi ) (setq e-hi  100 ) )
(setq dist (getint (strcat "\n  distance   <"  (rtos E-hi)  ">:")))
(if dist (setq e-hi dist))


(setq ent_set (entsel "\nSelect object to offset: "))
(while ent_set
(setq ent (car ent_set))
(setq p1 (getpoint "\nSide to offset? "))
(command "_.offset" dist ent_set p1 "" "")
(vlax-put-property (vlax-ename->vla-object (entlast)) 'layer off_lay)
(setq ent_set (entsel "\nSelect object to offset or : "))
(setvar "clayer" off_lay2)
)


)
« Last Edit: June 05, 2012, 11:01:13 AM by dussla »

Ketxu

  • Newt
  • Posts: 109
Re: offset lisp problem
« Reply #1 on: June 04, 2012, 11:20:27 PM »
Please post code in code tag.
In your code : (if dist (setq e_hi dist)) , so, what will happens if not dist ?

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: offset lisp problem
« Reply #2 on: June 05, 2012, 07:06:56 AM »
dussla,

Please read this.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: offset lisp problem
« Reply #3 on: June 10, 2012, 03:29:02 AM »
Check it out now .... and if you wanted to stop running the code , just hit enter instead of cancel button to reset the previous layer to current .

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ cl dist hi e p1)
  2.   (setq cl (getvar "clayer"))
  3.   (if (setq dist (cond ((getint (strcat "\n Specify offset distance   <"
  4.                                         (rtos (if (not hi)
  5.                                                 (setq hi 100.0)
  6.                                               )
  7.                                               2
  8.                                               1
  9.                                         )
  10.                                         ">:"
  11.                                 )
  12.                         )
  13.                        )
  14.                        (t hi)
  15.                  )
  16.       )
  17.     (progn
  18.       (setq hi dist)
  19.       (if (not (tblsearch "LAYER" "_temp-offset"))
  20.         (entmakex '((0 . "LAYER")
  21.                     (100 . "AcDbSymbolTableRecord")
  22.                     (100 . "AcDbLayerTableRecord")
  23.                     (2 . "_temp-offset")
  24.                     (70 . 0)
  25.                     (62 . 140)
  26.                     (6 . "Continuous")
  27.                    )
  28.         )
  29.       )
  30.       (setvar 'clayer "_temp-offset")
  31.       (while
  32.         (and (setq e (car (entsel "\nSelect object to offset: ")))
  33.              (setq p1 (getpoint "\n Side to offset? "))
  34.         )
  35.          (command "_.offset" "_Layer" "_Current" dist e p1 "" "")
  36.       )
  37.     )
  38.     (princ)
  39.   )
  40.   (setvar "clayer" cl)
  41.   (princ)
  42. )

pBe

  • Bull Frog
  • Posts: 402
Re: offset lisp problem
« Reply #4 on: June 10, 2012, 04:44:53 AM »
Code: [Select]
(setq dist (cond
          ((getdist
             (strcat
               "\nEnter Offset Distance [Enter to accept: <"
               (rtos (setq dist (abs (getvar 'Offsetdist))) 2 2)
               ">: "
               )
             )
           )
          (dist)
          ))

Code: [Select]
(command "_.offset"  "_Layer" "_Current"  dist  e p1 "" )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: offset lisp problem
« Reply #5 on: June 10, 2012, 09:32:26 AM »
More on the subject.
-------------   Offset  -----------------
Advanced Offset to both side by VVA <Vladimir Azarko>
Offset selected object to both side and change (optional) layer of new object to current
http://www.theswamp.org/index.php?topic=23069.0
http://www.theswamp.org/index.php?topic=39645.msg449444#msg449444
http://www.theswamp.org/index.php?topic=32743.0 VLA-Offset using Point Selection
http://www.theswamp.org/index.php?topic=24688.0 Staggered Multiple Offset by RonJonp
http://www.theswamp.org/index.php?topic=6209.0 Here is a nice example of Offset by Jürg Menzi
http://www.theswamp.org/index.php?topic=23921.0 Offset direction discussion
http://www.theswamp.org/index.php?topic=21933.msg266096#msg266096 Offset Segments by Gile
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.