TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: RolandOrzabal on September 19, 2012, 05:37:03 AM

Title: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 19, 2012, 05:37:03 AM
Hi can you guys help me with this routine? it looks like "reinventing the wheel" but this one make a rectangular revision cloud by first asking the user for arc distances, then for the Revision cloud style. Then the user picks 2 points and there goes the revision cloud. Then reason is that we use this either in paper/model space

My problem is that i want the value of distance 1 to show while inputing distance 2. While Dis1 value is shown, the user can either press enter or input another value provided that the value should be equal or greater than Dis1

this code forces the user to enter a value for Dis2, not accepting the shown value of Dis1

and after the routine is done and i want to repeat all, how can the code remember the Dis1 and Dis2 values so the user doesn't need to enter the values again?

Code: [Select]
(defun c:try (/ Dis1 Dis2 pt1 pt2 obj )
(setq old_osm (getvar "OSMODE"))
 (setvar "osmode" 0)
 (setvar 'cmdecho 0)
 (setq PLW (getvar "plinewid"))
 (setvar "plinewid" 0)
 (initget (+ 1 2 4))
 (while (= Dis1 nil)
(setq Dis1 (getreal "\nMin Arc Distance: "))
 )
 (while (= Dis2 nil)
(setq Dis2 (getreal (strcat"\nMax Arc Distance: <" (rtos Dis1) ">  ")))
 )
  (setq cont T)
    (while cont
        (setq cont nil)
        (initget "Normal / Calligraphic")
        (setq kw (getkword "\nRevcloud Style \nSelect option [ Normal / Calligraphic ] <Normal>:"))
(if (not kw) (setq kw "Normal"))
        (cond
            ((= kw "Normal") (C:RV_Normal))
            ((= kw "Calligraphic") (C:RV_Calligraphic))
)
)
(setq Dis1 nil)
(setq Dis2 nil)
(setvar "plinewid" PLW)
(setvar "cmdecho" cmd1)
)

(defun c:RV_Normal ()
(setq pt1 (getpoint "\nFirst corner of revison cloud: "))
(setq pt2 (getcorner "\nDiagonal corner of revision cloud " pt1))
(command "._RECTANG" pt1 pt2)
(setq obj (entlast))
(command "._revcloud" "style" "n" "ARC" Dis1 Dis2 "OBJECT" obj "" )
)

(defun c:RV_Calligraphic ()
(setq pt1 (getpoint "\nFirst corner of revison cloud: "))
(setq pt2 (getcorner "\nDiagonal corner of revision cloud " pt1))
(command "._RECTANG" pt1 pt2)
(setq obj (entlast))
(command "._revcloud" "style" "C" "ARC" Dis1 Dis2 "OBJECT" obj "")
)

(princ)
Title: Re: Help on my Rectangular RevCloud
Post by: ribarm on September 19, 2012, 07:14:00 AM
Replace lines from (initget ...) (while ...) (while ...) with this :

Code: [Select]
(initget (+ 2 4))
 (while (= Dis1 nil)
    (setq Dis1 (getreal (if a (strcat "\nMin Arc Distance <" (rtos a) "> : ") "\nMin Arc Distance :")))
    (if (null Dis1) (setq Dis1 a))
 )
 (while (= Dis2 nil)
    (setq Dis2 (getreal (if b (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " <" (rtos b) "> : ") (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " : "))))
    (if (null Dis2) (setq Dis2 b))
 )
 (setq a Dis1 b Dis2)
Title: Re: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 19, 2012, 07:24:05 AM
Replace lines from (initget ...) (while ...) (while ...) with this :

Code: [Select]
(initget (+ 2 4))
 (while (= Dis1 nil)
    (setq Dis1 (getreal (if a (strcat "\nMin Arc Distance <" (rtos a) "> : ") "\nMin Arc Distance :")))
    (if (null Dis1) (setq Dis1 a))
 )
 (while (= Dis2 nil)
    (setq Dis2 (getreal (if b (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " <" (rtos b) "> : ") (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " : "))))
    (if (null Dis2) (setq Dis2 b))
 )
 (setq a Dis1 b Dis2)

thanks MR! that worked! am going to use this also to make a polygonal revcloud.
cheers MR! thanks again!
Title: Re: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 19, 2012, 08:16:52 PM
M.R. tried the code again and found some "bug"

Dis2 should be equal or greater than Dis1. after entering Dis1 say 300 and Dis2 say 50, the routine continues to run.
i think it should pause until the user inputs a value equal or greater that Dis1

Thanks in advance
Title: Re: Help on my Rectangular RevCloud
Post by: ribarm on September 19, 2012, 11:49:13 PM
Try this :

Code: [Select]
(defun c:RV ( / Dis1 Dis2 old_osm cmd1 PLW )
 (setq old_osm (getvar "OSMODE"))
 (setq cmd1 (getvar "CMDECHO"))
 (setq PLW (getvar "plinewid"))
 (setvar "osmode" 0)
 (setvar "cmdecho" 0)
 (setvar "plinewid" 0)
 (initget (+ 2 4))
 (while (= Dis1 nil)
  (setq Dis1 (getreal (if a (strcat "\nMin Arc Distance <" (rtos a) "> : ") "\nMin Arc Distance :")))
  (if (null Dis1) (setq Dis1 a))
 )
 (while (= Dis2 nil)
  (setq Dis2 (getreal (if b (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " <" (rtos b) "> : ") (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " : "))))
  (if (null Dis2) (setq Dis2 b))
  (if (< Dis2 Dis1) (setq Dis2 nil))
 )
 (setq a Dis1 b Dis2)
 (initget "Normal Calligraphic")
 (setq kw (getkword "\nRevcloud Style \nSelect option [ Normal / Calligraphic ] <Normal>:"))
 (if (not kw) (setq kw "Normal"))
 (cond
  ((= kw "Normal") (C:RV_Normal))
  ((= kw "Calligraphic") (C:RV_Calligraphic))
 )
 (setvar "plinewid" PLW)
 (setvar "cmdecho" cmd1)
 (setvar "osmode" old_osm)
 (princ)
)

(defun c:RV_Normal ( / pt1 pt2 obj )
 (setq pt1 (getpoint "\nFirst corner of revison cloud : "))
 (setq pt2 (getcorner "\nDiagonal corner of revision cloud " pt1))
 (command "._RECTANG" pt1 pt2)
 (setq obj (entlast))
 (command "._revcloud" "style" "n" "ARC" Dis1 Dis2 "OBJECT" obj "" )
 (princ)
)

(defun c:RV_Calligraphic ( / pt1 pt2 obj )
 (setq pt1 (getpoint "\nFirst corner of revison cloud : "))
 (setq pt2 (getcorner "\nDiagonal corner of revision cloud " pt1))
 (command "._RECTANG" pt1 pt2)
 (setq obj (entlast))
 (command "._revcloud" "style" "C" "ARC" Dis1 Dis2 "OBJECT" obj "")
 (princ)
)

M.R.
Title: Re: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 20, 2012, 01:55:55 AM
Try this :

Code: [Select]
(defun c:RV ( / Dis1 Dis2 old_osm cmd1 PLW )
 (setq old_osm (getvar "OSMODE"))
 (setq cmd1 (getvar "CMDECHO"))
 (setq PLW (getvar "plinewid"))
 (setvar "osmode" 0)
 (setvar "cmdecho" 0)
 (setvar "plinewid" 0)
 (initget (+ 2 4))
 (while (= Dis1 nil)
  (setq Dis1 (getreal (if a (strcat "\nMin Arc Distance <" (rtos a) "> : ") "\nMin Arc Distance :")))
  (if (null Dis1) (setq Dis1 a))
 )
 (while (= Dis2 nil)
  (setq Dis2 (getreal (if b (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " <" (rtos b) "> : ") (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " : "))))
  (if (null Dis2) (setq Dis2 b))
  (if (< Dis2 Dis1) (setq Dis2 nil))
 )
 (setq a Dis1 b Dis2)
 (initget "Normal Calligraphic")
 (setq kw (getkword "\nRevcloud Style \nSelect option [ Normal / Calligraphic ] <Normal>:"))
 (if (not kw) (setq kw "Normal"))
 (cond
  ((= kw "Normal") (C:RV_Normal))
  ((= kw "Calligraphic") (C:RV_Calligraphic))
 )
 (setvar "plinewid" PLW)
 (setvar "cmdecho" cmd1)
 (setvar "osmode" old_osm)
 (princ)
)

(defun c:RV_Normal ( / pt1 pt2 obj )
 (setq pt1 (getpoint "\nFirst corner of revison cloud : "))
 (setq pt2 (getcorner "\nDiagonal corner of revision cloud " pt1))
 (command "._RECTANG" pt1 pt2)
 (setq obj (entlast))
 (command "._revcloud" "style" "n" "ARC" Dis1 Dis2 "OBJECT" obj "" )
 (princ)
)

(defun c:RV_Calligraphic ( / pt1 pt2 obj )
 (setq pt1 (getpoint "\nFirst corner of revison cloud : "))
 (setq pt2 (getcorner "\nDiagonal corner of revision cloud " pt1))
 (command "._RECTANG" pt1 pt2)
 (setq obj (entlast))
 (command "._revcloud" "style" "C" "ARC" Dis1 Dis2 "OBJECT" obj "")
 (princ)
)

M.R.


Great Marko! Thanks a lot! just how i wanted it to be!
cheers!
Title: Re: Help on my Rectangular RevCloud
Post by: jbuzbee on September 20, 2012, 09:27:37 AM
Another option: dynamic block - see attached dwg

Now I use a custom lisp that checks to see if the block exists, if not, imports it from a "standards" drawing then puts it on the A-Anno-Revs layer.  But maybe the dblock can get you started.

jb
Title: Re: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 20, 2012, 09:46:11 AM
Another option: dynamic block - see attached dwg

Now I use a custom lisp that checks to see if the block exists, if not, imports it from a "standards" drawing then puts it on the A-Anno-Revs layer.  But maybe the dblock can get you started.

jb

thanks for the suggestion...
i finally managed to wrap up this this routine..

thanks to MR for the help

i added an option to make a polygonal revcloud too aside from this rectangular
Title: Re: Help on my Rectangular RevCloud
Post by: ronjonp on September 20, 2012, 09:57:09 AM
Have you seen this?  http://www.theswamp.org/index.php?topic=1319.msg16634#msg16634
Title: Re: Help on my Rectangular RevCloud
Post by: CAB on September 20, 2012, 10:07:41 AM
Thanks Ron, maybe I should add a Draw Option for Rectangle.
My draw pline is a vertex pick along route method.
Title: Re: Help on my Rectangular RevCloud
Post by: ronjonp on September 20, 2012, 10:10:41 AM
Thanks Ron, maybe I should add a Draw Option for Rectangle.
My draw pline is a vertex pick along route method.

I figured Command: POLYGON and then use the pick option in your routine would cover most anything :)
Title: Re: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 20, 2012, 10:13:59 AM
@Ron;

thanks! haven't seen that yet.
but i believe this routine needs a pre-drawn polyline (havent tried it yet)

i want to do the revcloud straight away without the pre-drawn polyline

@Cab;
i will try to post the routine tomorrow
am sure there will be many improvements on that coz am just new..

i will try out your code tomorrow too coz am on mobile now
Title: Re: Help on my Rectangular RevCloud
Post by: CAB on September 20, 2012, 02:23:32 PM
I think you may like it. Uploading version 2.9 now which I added the Rectangle Draw option.
Be sure to extract the SLD file to your ACAD search path.

;;;  Files Required to be in the ACAD search path
;;;     pl2cloud.dcl  ; ***  note- created by this lisp
;;;     rc_normal.sld ; slides are found in the zip file
;;;     rc_shadow.sld
;;;     rc_length.sld
Title: Re: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 20, 2012, 08:28:00 PM
I think you may like it. Uploading version 2.9 now which I added the Rectangle Draw option.
Be sure to extract the SLD file to your ACAD search path.

;;;  Files Required to be in the ACAD search path
;;;     pl2cloud.dcl  ; ***  note- created by this lisp
;;;     rc_normal.sld ; slides are found in the zip file
;;;     rc_shadow.sld
;;;     rc_length.sld


WOW! that is very nice CAB!

if i've seen it before i wouldn't have the need to make mine :D
thanks a lot!

anyway, here's what i got

Code: [Select]
(defun c:RV ( / Dis1 Dis2 old_osm cmd1 PLW )
 (setq old_osm (getvar 'OSMODE ))
 (setq cmd1 (getvar "CMDECHO"))
 (setq PLW (getvar "plinewid"))
 (setvar "osmode" 0)
 (setvar "cmdecho" 0)
 (setvar "plinewid" 0)
 ;; thanks to ribarm for fixing this line
 (initget (+ 2 4))
(while (= Dis1 nil)
(setq Dis1 (getreal (if a (strcat "\nMin Arc Distance <" (rtos a) "> : ") "\nMin Arc Distance :")))
(if (null Dis1) (setq Dis1 a))
)
(while (= Dis2 nil)
(setq Dis2 (getreal (if b (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " <" (rtos b) "> : ") (strcat "\nMax Arc Distance - must be greater than " (rtos Dis1) " : "))))
(if (null Dis2) (setq Dis2 b))
(if (< Dis2 Dis1) (setq Dis2 nil))
)
(setq a Dis1 b Dis2)
;; until this line as commented by ribarm
  (setq cont T)
    (while cont
        (setq cont nil)
        (initget "RN / RC / PN / PC / ?")
        (setq kw (getkword "\nRevcloud Style \nSelect option [ RN / RC / PN / PC / ?] <RN>:"))
(if (not kw) (setq kw "RN"))
        (cond
            ((= kw "RN") (C:NOD_RN))
            ((= kw "RC") (C:NOD_RC))
            ((= kw "PN") (C:NOD_PN))
            ((= kw "PC") (C:NOD_PC))
            ((= kw "?")
             (textscr)
             (alert
                 (strcat
                     "
OPTIONS:

   RN : Rectangular Revcloud in Normal Style
   RC : Rectangular Revcloud in Calligraphic Style
   PN : Polygonal Revcloud in Normal Style
   PC : Polygonal Revcloud in Calligraphic Style
   ")
             )
             (setq cont T)
            )
        )
    )
(setq Dis1 nil)
(setq Dis2 nil)
(setvar "plinewid" PLW)
(setvar "cmdecho" cmd1)
(setvar 'osmode old_osm)

)

(defun c:NOD_RN ()
(print "Rectangular Revcloud Normal Style Selected")
(setq pt1 (getpoint "\nFirst corner of revison cloud: "))
(setq pt2 (getcorner "\nDiagonal corner of revision cloud " pt1))
(command "._RECTANG" pt1 pt2)
(setq obj (entlast))
(command "._revcloud" "style" "n" "ARC" Dis1 Dis2 "OBJECT" obj "" )
)

(defun c:NOD_RC()
(print "Rectangular Revcloud Calligraphic Style Selected")
(setq pt1 (getpoint "\nFirst corner of revison cloud: "))
(setq pt2 (getcorner "\nDiagonal corner of revision cloud " pt1))
(command "._RECTANG" pt1 pt2)
(setq obj (entlast))
(command "._revcloud" "style" "C" "ARC" Dis1 Dis2 "OBJECT" obj "")
)

(defun C:NOD_PN ()
(prompt "\nPolygonal Revcloud Normal Style Selected\nPick Starting Point of Polyline and close when done:")
(command "_.PLINE")
(while (= (getvar "CMDNAMES") "PLINE")
(command pause)
)
(command "pedit" "l" "c" "")
(command "._revcloud" "style" "n" "ARC" Dis1 Dis2 "OBJECT" "l" "no")
)

(defun C:NOD_PC ()
(prompt "\nPolygonal Revcloud Calligraphic Style Selected\nPick Starting Point of Polyline and close when done:")
(command "_.PLINE")
(while (= (getvar "CMDNAMES") "PLINE")
(command pause)
)
(command "pedit" "l" "c" "")
(command "._revcloud" "style" "c" "ARC" Dis1 Dis2 "OBJECT" "l" "no")
)
(princ)

but still its ok.. i learn something from this anyway.
Title: Re: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 21, 2012, 10:46:49 PM
question :

why is the OSMODE value apprearing at the end of the routine?
Title: Re: Help on my Rectangular RevCloud
Post by: Kerry on September 21, 2012, 11:00:08 PM
because it was the last statement evaluated in the routine

modify to
Code - Auto/Visual Lisp: [Select]
  1. ;; < .. remainder not shown ... >
  2.    (setvar 'osmode old_osm)
  3.    (princ)             ;;<<<--- add
  4. )
Title: Re: Help on my Rectangular RevCloud
Post by: RolandOrzabal on September 22, 2012, 12:10:29 AM
because it was the last statement evaluated in the routine

modify to
Code - Auto/Visual Lisp: [Select]
  1. ;; < .. remainder not shown ... >
  2.    (setvar 'osmode old_osm)
  3.    (princ)             ;;<<<--- add
  4. )


I see! thanks a lot Kerry!
that worked!
Title: Re: Help on my Rectangular RevCloud
Post by: Kerry on September 22, 2012, 12:51:12 AM

You're welcone noddy.