Author Topic: Setbacks Creator  (Read 27685 times)

0 Members and 1 Guest are viewing this topic.

SMadsen

  • Guest
Setbacks Creator
« Reply #45 on: October 03, 2003, 07:26:39 PM »
Thanks Mark - you pointed out the most important thing about VL-CMDF (which I naturally forgot to tell). VL-CMDF returns T on success and nil on failure.

That's a very nice example showing exactly how handy that feature is.

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Setbacks Creator
« Reply #46 on: October 06, 2003, 03:55:38 PM »
That makes sense then...Now I will just need to figure out which areas would be good to use the vl-cmdf for me, and where not too. Well, I didn't see any answers to my post regarding the multiple selection sets, so I am going to post what I had and ask a few other questions to clerify things.

Code: [Select]
(defun offsetrear (offpt side ss / ent lastent)
  (if (not ssrear)
    (setq ssrear (ssadd))
  )
  (setvar "ERRNO" 0)
  (while
    (setq lastent (entlast))
    (command ".OFFSET" "10" ent offpt "")
    (cond
      ((not (eq lastent (entlast)))
   (ssadd (entlast) ssrear)
      )
    )
  )
  (if (< 0 (sslength ssrear))
    ssrear
  )
)


This is exactly the same as Stig's original offset function, but it is for offseting rear lot lines for the use of building the lot flowlines. Now the major problem, is that I don't want to have the user going through, and selecting lot lines too many times. So if it is at all possible, I would like to add the rear and side yard lot lines to two other selection sets, including the original. Is that even possible??? I know that I could add all of the items to multiple selection sets by doing something like:

Code: [Select]
(defun offsetrear (offpt side ss / ent lastent)
  (if (not ssrear)
    (setq ssrear (ssadd))
  )
  (setvar "ERRNO" 0)
  (while
    (setq lastent (entlast))
    (command ".OFFSET" "10" ent offpt "")
    (cond
      ((not (eq lastent (entlast)))
   (ssadd (entlast) ssrear)
   [b](ssadd (entlast) ssside)[/b]
      )
    )
  )
  [b](if (< 0 (sslength ssrear)
      (< 0 (sslength ssside)
  ))
    ssrear
    ssside
  )[/b]
)


Now I believe that would work...I have yet to have the chance to test it out. With that in play, I am able to add all of the objects that the user selects to two entirely different selection sset's, but that does not give me any so called filtering for the side and rear lot lines. Now if I can get the lot lines from these new ssets that I want to create, then I should be able to go through and fillet each of the entities within, and finally break the ents by using polar a bit...correct me if I am wrong, or try to point me in a better direction if you see one.

Rug
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

Anonymous

  • Guest
Setbacks Creator
« Reply #47 on: October 18, 2003, 12:27:12 PM »
rug,

it has been a few days and no one has posted so I hope you don't mind.

I was playing with your routine and LEARNING a lot...

I added a few items trying to figure things out & working on the swale.

I added the beginings of the swale creation but also got stuck,
It would seem that bpoly would make it easy to create a rectangle of the swale area but you would still have the radius to deal with as well as the front line of the swale to erase.

I can't see a way to creatre the swale lines without the end points. :(

Code added by me is marked with   ;;  CAB

Code: [Select]
(defun GETVALUE (VAL SIDE / PRMPT INIT INQUIRY)
  (if (and (numberp VAL) (> VAL 0.0))
 ;<- If 'val' is a real number and greater than 0, continue
    (setq PRMPT
  (strcat "Specify " SIDE " yard setback <" (rtos VAL) ">: ")
 INIT 6
    )
    (setq PRMPT (strcat "Specify " SIDE " yard setback: ")
 INIT 7
    )
  )
  (initget INIT) ; gets the number supplied above
  (if (setq INQUIRY (getdist PRMPT))
 ; sets 'inquiry' to the distance from 'prmpt'
    (setq VAL INQUIRY) ; sets val to distance recieved from last line
;;; otherwise VAL is still equal to VAL, i.e. the default value
  )
  VAL ; returns val
)


(defun OFFSETOBJECT (OFFDIST OFFPT SIDE SS / ENT LASTENT)
  (if (not SS)
    (setq SS (ssadd)); creates an empty selection set
  )
  (if (not ssswale)
    (setq ssswale (ssadd)); creates an empty selection set
  )
  (setvar "ERRNO" 0) ; reset to 0, so that the loop below works.
  (while
    (and (setq ENT (car (entsel (strcat "\nSelect " SIDE " lot lines: "))))
 ; prompts to select current side lot lines,
 ; returns entname w/ car set that entity to
 ; ent and gets errno and continues if errno
 ; not equal to 52
(/= (getvar "ERRNO") 52)
;;; sysvar ERRNO will be set (automatically by AutoCAD) to 52 if entity
;;; selecting with ENTSEL fails. This gives you a chance to exit the loop
;;; by simply hitting space (or clicking in empty drawing area which should
;;; not happen, but you can play with that particular case :)
    )

     (setq LASTENT (entlast)) ;;; saves the last entity added


  ;;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV  CAB
  ;;  Create swale lines & save in selection set
     (cond
       ((= SIDE "Rear")  (command ".OFFSET" 10 ENT OFFPT "") ; offsets
)
       ((= SIDE "Side")  (command ".OFFSET" 2 ENT OFFPT "") ; offsets
)
       ((= SIDE "Front")  (command ".OFFSET" 2 ENT OFFPT "") ; offsets
)
     )
     (cond ((not (eq LASTENT (entlast))) ; if entity does not equal last ent, continue
   (ssadd (entlast) ssswale) ; adds new entity to ssswale
   (command ".CHPROP" (entlast) "" "Layer" "SWALE" "") ; changes properties of last entity
  )
     )
  ;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  CAB


     (command ".OFFSET" OFFDIST ENT OFFPT "") ; offsets
     (cond ((not (eq LASTENT (entlast))) ; if entity does not equal last ent, continue
   (ssadd (entlast) SS) ; adds new entity to ss
  )
     )
  )
;;; if there are entities in the selection set then return it,
;;; otherwise return nil (if will fail and return nil)
  (if (< 0 (sslength SS))
    SS
  )
)

;;**********************************************************
;;                    Main function
;;**********************************************************
(defun C:SB (/       FRONTOFF SIDEOFF   REAROFF   USERLAY
    USERCMD   USEROSM USERFILL  OSP     TMP
    SSET      ENT LASTENT   MYPROMPT  *ERROR* tmpval ssswale
   )

  (defun *ERROR* (MSG)
    (if MSG ; only display a message if MSG is NOT nil
      (princ (strcat "Rugaroo made an error: " MSG))
    )
    (foreach VAR '(("clayer" USERLAY)
  ("cmdecho" USERCMD)
  ("orthomode" USERORTH)
  ("osmode" USEROSM)
  ("filletrad" USERFILL)
 )
      (if (eval (cadr VAR))
 ; if each uservar evaluate the 2nd item is present
(setvar (car VAR) (eval (cadr VAR)))
 ; like doing setvar "clayer" "something", and so on with all uservars in var
;;; ^correct. Because variables are provided in a quoted list, they will have
;;; to be "ripped open" to read the value they hold. EVAL does this.
      )
    )
    (princ)
  )

  (setq USERLAY (getvar "clayer")
USERCMD (getvar "cmdecho")
USERORTH (getvar "orthomode")
USEROSM (getvar "osmode")
USERFILL (getvar "filletrad")
  )
  (setvar "cmdecho" 0)
  (setvar "orthomode" 0)
  (setvar "filletrad" 0)

  ;;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV  CAB
  ;; added code to test data from acadcfg file in case it is missing
  (setq FRONTOFF (If (setq tmpval (getcfg "AppData/Setbacks/Front"))
  (distof tmpval)
  25 ; default value if not in acadcfg file
)
SIDEOFF (If (setq tmpval (getcfg "AppData/Setbacks/Side"))
  (distof tmpval)
  7
)
REAROFF (If (setq tmpval (getcfg "AppData/Setbacks/Rear"))
  (distof tmpval)
  20
)
  )
  ;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  CAB

  (setq FRONTOFF (GETVALUE FRONTOFF "Front") ; go get front offset value
SIDEOFF (GETVALUE SIDEOFF "Side")
REAROFF (GETVALUE REAROFF "Rear")
  )

  (command ".LAYER" "Make" "SWALE" "") ;make Swale layer current   CAB
  (command "undo" "begin")  ;;  CAB

  (cond ((and FRONTOFF
     SIDEOFF
     REAROFF
     (setq OSP (getpoint "\nPick the center of the lot: "))
 ; as long as f.off, s.off, r.off are present continue, but if not an error?
)
;; save the setbacks into our config file
(setcfg "AppData/Setbacks/Front" (rtos FRONTOFF))
(setcfg "AppData/Setbacks/Side" (rtos SIDEOFF))
(setcfg "AppData/Setbacks/Rear" (rtos REAROFF))

(setvar "osmode" 0) ;;  CAB turn off so it wont interfear ?
;;  next let user pick property lines
(setq SSET (OFFSETOBJECT FRONTOFF OSP "Front" NIL)
      SSET (OFFSETOBJECT SIDEOFF OSP "Side" SSET)
      SSET (OFFSETOBJECT REAROFF OSP "Rear" SSET)
)

(setq LASTENT (entlast)) ; grabs the last entity created/added
(command ".BPOLY" OSP "") ;bpoly from osp
(cond ((not (eq (entlast) LASTENT))
 ; as long as a bpoly is made and does not equal above lastent, continue
(command ".LAYER" "Make" "SETBACKS" "") ;make out layer
(command ".CHPROP" (entlast) "" "Layer" "SETBACKS" "") ; changes properties of our bpoly
(command ".ERASE" SSET "") ; erases our selection set
(command ".EXPLODE" (entlast)) ;explodes our bpoly
(princ "\n\nSetbacks created...") ;ALL DONE!!!!
      )
      (t (princ "\nNo luck today :-(")) ; error, failed to create setbacks
)
)
  )

  (command "undo" "end")  ;;  CAB

  (*ERROR* NIL) ; call to error routine with nil so no message is displayed but uaer variables are saved
) ; end defun main


Anonymous

  • Guest
Setbacks Creator
« Reply #48 on: October 18, 2003, 12:31:20 PM »
Another question??

Why are the subroutines added at the begining?

Wouldn't it read easer if they were after the

Code: [Select]
(C:main ()
....code
) ; end main

(defun subroutines
)



Just curious..

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Setbacks Creator
« Reply #49 on: October 18, 2003, 12:45:03 PM »
Guess I was logged out...

Last two post..

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

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Setbacks Creator
« Reply #50 on: October 18, 2003, 01:29:04 PM »
Quote from: CAB
Another question??
Why are the subroutines added at the begining?
Wouldn't it read easer if they were after the
Code: [Select]
(C:main ()
....code
) ; end main
(defun subroutines
)


Just curious..


It's user prefence I suppose, I like my subr's on the top. :D
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
Setbacks Creator
« Reply #51 on: October 20, 2003, 10:42:52 AM »
...and with that preference Mark, you've talked a few others of us to do likewise.

SMadsen

  • Guest
Setbacks Creator
« Reply #52 on: October 20, 2003, 10:57:53 AM »
In many other languages, sequence of subroutines are essential (either that or specifying directives that forces a compiler to load in other sequences).

Because the main routine - in most cases the C: routine in AutoLISP - is just a function that connects the bits and pieces of the real work horses, it falls natural for many to put it where it should be put in other languages: at the end.
I mostly find it logical to put it at the bottom but AutoLISP loads everything at once so, as Mark points out, it's a matter of flavor.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Setbacks Creator
« Reply #53 on: October 20, 2003, 12:32:13 PM »
Thanks Guys for the explanation...

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

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Setbacks Creator
« Reply #54 on: October 22, 2003, 04:41:49 PM »
CAB -

I looked through what you had, and I am glad that I am not the only one getting confused on how to handle this.

To do the fillet of the swale objects, could we possibly try doing something like getting the first entity in our ssswale set (entity 0), and then do something like a  foreach entity in ssswale, setvar filletrad 5, setq swaleent1 entity 0, then setq swaleentX with 1+ for each entity in the list....is this making sense?

Rug
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017