automated revision cloud?

Discussion in 'AutoCAD' started by Michael Pape & Associates, Aug 5, 2004.

  1. We use the revision cloud in express tools to draw shrub masses. What we do
    is create a boundary around the area where the mass is, offset the boundary
    1' to the inside, set the revision cloud to 3.4', set the snap to nearest
    and then draw the revision cloud counter clockwise tracing the offset
    boundary to make a nice, neat, even cloud. This can get tedious if there
    are lots of masses or very large ones. Is there a way to write a lisp
    routine that would allow you to click on the offset line and have the
    revision cloud trace it automatically instead of doing it manually? (Or any
    other way that would create the same effect without having to trace the
    line.) Thanks! Allison
     
    Michael Pape & Associates, Aug 5, 2004
    #1
  2. Michael Pape & Associates

    Murph Guest

    With the rev-cloud command in R2005 you can select the offset boundary and
    use the "object" option. If you don't have 2005 yet then how about creating
    a custom line type of the arcs and change the linetype property to the
    offset boundary?

    Murph
     
    Murph, Aug 5, 2004
    #2
  3. Still on 2002. I've not had any luck with linetypes with arcs. I messed
    around in the linetype text file and done some stuff there, but I wasn't
    even sure you could make linetypes with arcs as I've never come across one.

    I'll have to hunt up a sample and edit it. Thanks!

    Thanks Allen for the custom cloud, I'm going to go try that right now!

    Allison
     
    Michael Pape & Associates, Aug 5, 2004
    #3
  4. Michael Pape & Associates

    Murph Guest

    I did a quick check before I posted and didn't have any decent results
    either using short lines or arc in a linetype. However I do have a
    "footprint" line type that converted.

    Murph
     
    Murph, Aug 5, 2004
    #4
  5. Michael Pape & Associates

    Tim Guest

    Go to my website and look under linetypes, there is 1 there that I created a
    few years ago that might be what you need.

    http://www.webofwilson.us

    Tim W.
     
    Tim, Aug 5, 2004
    #5
  6. Thanks Tim, I'll go grab that now and try it!

     
    Michael Pape & Associates, Aug 5, 2004
    #6
  7. I didn't have any luck with the lisp routines (I'm working in 2002 if that
    matters). When I load roughen, it doesn't give me a problem, but when I try
    to load cloud, then it says it can't load roughen, and when I type RC it
    says unknown command. I tried removing the "load roughen" line since I had
    loaded it manually, but that didn't help. Do you have a quick fix? I'd
    really like to try the lisp. Thanks Allison
     
    Michael Pape & Associates, Aug 5, 2004
    #7
  8. Oops, you also need these routines! Paste them into the cloud.lsp.
    Sorry.
    ;;-----------------------------------------------------------------------------------------

    ;; (MODESET) sets system variables to values as indicated in the
    ;; list variable 'a' where the format of 'a' is '("VAR" setting ...)
    ;; Previous settings of the sysvars are saved in 'MLST' for restoring
    ;; by issuing the command (MODER). You can repeatedly call (MODESET)
    ;; and it will append sysvars to 'MLST'

    (defun MODESET (a)
    (if (not MLST) (setq MLST '()))
    (repeat (/ (length a) 2)
    (if (eval (cadr a))
    (progn
    (setq MLST (append MLST (list (list (car a) (getvar (car a))))))
    (setvar (car a) (eval (cadr a)))
    )
    )
    (setq a (cddr a))
    )
    (princ))

    ;;-----------------------------------------------------------------------------------------

    (defun MODER (/ tmp_error)

    (repeat (length MLST)
    (setvar (caar MLST) (cadar MLST))
    (setq MLST (cdr MLST))
    )
    (setq MLST nil)
    (princ))

    ;;-----------------------------------------------------------------------------------------
     
    Allen Johnson, Aug 5, 2004
    #8
  9. Ok, I pasted that in. I still had to remove the load roughen command
    because it won't run if that's in there. Now I get this message:

    Select a Polyline to convert to a cloud: (I then pick a closed polyline)
    0.125
    Error: no function definition: OS_OFF

    I've tried it with the snaps on and off. Any ideas?
     
    Michael Pape & Associates, Aug 5, 2004
    #9
  10. Yeah, OS_OFF and OS_ON are more of my autoloaded "helper" routines!
    We'll get there someday!

    ;;--------------------------------------------------------------------------------------------------
    -

    ;; Toggles osnap mode functions for autolisp functions
    ;; Setting bit 16384 in OSMODE toggles OSNAP off &
    ;; resetting bit 16384 toggles OSNAP back on
    ;; Works by simulating a double click the OSNAP button
    ;; on the status bar. Not documented in Customization
    ;; Manual but in the Readme files...

    (defun os_off ()
    (setvar "osmode" (logior 16384 (getvar "osmode")))
    )
    (defun os_on ()
    (setvar "osmode" (logand (~ 16384) (getvar "osmode")))
    )

    ;;--------------------------------------------------------------------------------------------------
    -
     
    Allen Johnson, Aug 5, 2004
    #10
  11. Michael Pape & Associates

    T.Willey Guest

    Try this one. It from a larger routine, so no undo and no turning off of osnaps, so you might have to run it with osnaps off. After loading type "(pcloud)" at the command prompt.

    Hope it helps.
    Tim

    (defun pcloud ()

    (setq pcd1 (entsel "\nSelect closed polyline: "))
    (if pcd1
    (if (and (= (cdr (assoc 0 (setq pcd1 (entget (car pcd1))))) "LWPOLYLINE") (= (cdr (assoc 70 pcd1)) 1))
    (verticepoints pcd1)
    (princ "\nObject selected is not a polyline, or is not a closed polyline. ")
    )
    (princ "\n Nothing selected: ")
    )
    )

    ;=========================================

    (defun VerticePoints(poly1 / n vpl)

    (setq n 0)
    (while (nth n poly1)
    (if (= (car (nth n poly1)) 10)
    (setq vpl (append vpl (list (cdr (nth n poly1)))))
    )
    (setq n (1+ n))
    )
    (command "_.erase" (cdr (assoc -1 pcd1)) "")
    (if (> (angle (car vpl) (cadr vpl)) 3.14159)
    (setq vpl (reverse vpl))
    )
    (getangs (reverse vpl))
    )

    ;================================================

    (defun getangs (vpts / alist dlist)

    (setq vpts (append vpts (list (car vpts))))
    (while (> (vl-list-length vpts) 1)
    (setq alist (append alist (list (angle (car vpts) (cadr vpts)))))
    (setq dlist (append dlist (list (distance (car vpts) (cadr vpts)))))
    (setq vpts (cdr vpts))
    )
    (drpcld alist dlist (car vpts))
    )

    ;=================================================

    (defun drpcld (ang0 dist0 start / dist2 pt1 sc1 cdsc pclss cnt1 cnt2 rad1 adist)

    (if (>= (getvar"cvport") 2)
    (setq sc1 (getvar "DIMSCALE"))
    (setq sc1 1)
    )
    (setq dist2 0
    pt1 start
    dist1 (car dist0)
    ang1 (car ang0)
    cdsc (* sc1 0.03125)
    rad1 0.65
    pclss (ssadd)
    cnt1 (vl-list-length dist0)
    cnt2 1
    )
    (if (> dist1 3)
    (setq adist 1.0)
    (setq adist (* dist1 0.3333))
    )
    (repeat cnt1
    (while (< dist2 dist1)
    (if (and (> (1+ dist2) dist1) (= cnt2 cnt1))
    (progn
    (setq pt2 start)
    (setq rad1 (* (distance pt1 pt2) 0.65))
    )
    (setq pt2 (polar pt1 ang1 adist))
    )
    (command "_.arc" pt1 "e" pt2 "r" rad1)
    (command "_.pedit" (entlast) "y" "e" "w" cdsc "0" "x" "")
    (ssadd (entlast) pclss)
    (setq dist2 (1+ dist2)
    pt1 pt2
    )
    )
    (setq dist2 0
    ang0 (cdr ang0)
    ang1 (car ang0)
    dist0 (cdr dist0)
    dist1 (car dist0)
    cnt2 (1+ cnt2)
    )
    (if dist1
    (if (> dist1 3)
    (setq adist 1.0)
    (setq adist (* dist1 0.3333))
    )
    )
    )
    (command "_.pedit" "m" pclss "" "j" "" "")

    )
     
    T.Willey, Aug 5, 2004
    #11
  12. Boy, and I thought I had my autocad personalized :) Ok, we're getting
    closer. It worked in one drawing, but when I tried it in another (created
    the closed polyline the same way in both drawings) I got:

    Select a Polyline to convert to a cloud:
    0.125
    Error: divide by zero
    Enter a vertex editing option
    [Next/Previous/Break/Insert/Move/Regen/Straighten/Tangent/Width/eXit] <N>:

    And dumped me into polyline edit.

    When it does work, I would like the arcs to be consistent and controllable
    as far as their size, is that possible? They were quite random.

    Thanks for your patience, if you're getting tired of me, just say so and
    I'll make do with what I have!

    Allison
     
    Michael Pape & Associates, Aug 5, 2004
    #12
  13. Rats! I'm having no luck today. When I load it and click a closed polyline
    I just drew I get:

    Object selected is not a polyline, or is not a closed polyline. "\nObject
    selected is not a polyline, or is not a closed polyline. "

    Could it be a lightweight polyline thing?


    osnaps, so you might have to run it with osnaps off. After loading type
    "(pcloud)" at the command prompt.
    "LWPOLYLINE") (= (cdr (assoc 70 pcd1)) 1))
     
    Michael Pape & Associates, Aug 5, 2004
    #13
  14. To eliminate the randomness, try setting RF_roughness to zero.
    What the routine is doing is splitting the polyline into short segments, then randomly moving them
    so that the line "jiggles".
    Setting the amount of roughness to zero should remove the "jiggles".
    I'm guessing that the divide by zero error is possibly because the length of the original polyline
    segment to be broken up was shorter than the mindist variable. I haven't checked that out though.
    Another possibility - I use the system variable "USERR3" for the drawing scale factor (i.e. 96 for
    1/8") - make sure that USERR3 is not zero.
     
    Allen Johnson, Aug 5, 2004
    #14
  15. Michael Pape & Associates

    T.Willey Guest

    It looks like it might be the way you closed it. Did you pick the last point? or did you type "c" to close it? Try typing "c" to close it and then try again.

    Tim
     
    T.Willey, Aug 5, 2004
    #15
  16. I did c for close. I'll try it in a new drawing and see what happens.

    point? or did you type "c" to close it? Try typing "c" to close it and then
    try again.
     
    Michael Pape & Associates, Aug 5, 2004
    #16
  17. Michael Pape & Associates

    Tim Guest

    Make sure you really are picking a LWpolyline..I thought I was to until I
    listed the line and it wasn't so I ran "convertpoly" and fixed it..routine
    ran fine after that.

    Tim W.
     
    Tim, Aug 5, 2004
    #17
  18. Michael Pape & Associates

    T.Willey Guest

    Try this one. I made a few improvements.

    Tim

    (defun pcloud (/ op1)

    (setq pcd1 (entsel "\nSelect closed polyline: "))
    (if pcd1
    (if (= (cdr (assoc 0 (setq pcd1 (entget (car pcd1))))) "LWPOLYLINE")
    (if (= (cdr (assoc 70 pcd1)) 1)
    (verticepoints pcd1)
    (progn
    (initget "Y N")
    (setq op1 (getkword "\nPolyline is not closed. Would you like to close it? [<Y>,N]: "))
    (if (not op1)
    (setq op1 "Y")
    ); if
    (if (= (strcase op1) "Y")
    (progn
    (setq pcd1 (subst (cons 70 1) (assoc 70 pcd1) pcd1))
    (entmod pcd1)
    (entupd (cdr (assoc -1 pcd1)))
    (verticepoints pcd1)
    ); progn
    (vl-exit-with-value nil)
    ); if
    );progn
    ); if
    (princ "\nObject selected is not a polyline. ")
    ); if
    (princ "\n Nothing selected: ")
    )
    )

    ;=========================================

    (defun VerticePoints(poly1 / n vpl)

    (setq n 0)
    (while (nth n poly1)
    (if (= (car (nth n poly1)) 10)
    (setq vpl (append vpl (list (cdr (nth n poly1)))))
    )
    (setq n (1+ n))
    )
    (command "_.erase" (cdr (assoc -1 pcd1)) "")
    (if (= op1 "Y")
    (setq vpl (reverse (cdr (reverse vpl))))
    )
    (if (> (angle (car vpl) (cadr vpl)) 3.14159)
    (setq vpl (reverse vpl))
    )
    (getangs (reverse vpl))
    )

    ;================================================

    (defun getangs (vpts / alist dlist)

    (setq vpts (append vpts (list (car vpts))))
    (while (> (vl-list-length vpts) 1)
    (setq alist (append alist (list (angle (car vpts) (cadr vpts)))))
    (setq dlist (append dlist (list (distance (car vpts) (cadr vpts)))))
    (setq vpts (cdr vpts))
    )
    (drpcld alist dlist (car vpts))
    )

    ;=================================================

    (defun drpcld (ang0 dist0 start / dist2 pt1 sc1 cdsc pclss cnt1 cnt2 rad1 adist)

    (if (>= (getvar"cvport") 2)
    (setq sc1 (getvar "DIMSCALE"))
    (setq sc1 1)
    )
    (setq dist2 0
    pt1 start
    dist1 (car dist0)
    ang1 (car ang0)
    cdsc (* sc1 0.03125)
    rad1 0.65
    pclss (ssadd)
    cnt1 (vl-list-length dist0)
    cnt2 1
    )
    (if (> dist1 3)
    (setq adist 1.0)
    (setq adist (* dist1 0.3333))
    )
    (repeat cnt1
    (while (< dist2 dist1)
    (if (and (> (1+ dist2) dist1) (= cnt2 cnt1))
    (progn
    (setq pt2 start)
    (setq rad1 (* (distance pt1 pt2) 0.65))
    )
    (setq pt2 (polar pt1 ang1 adist))
    )
    (command "_.arc" pt1 "e" pt2 "r" rad1)
    (command "_.pedit" (entlast) "y" "e" "w" cdsc "0" "x" "")
    (ssadd (entlast) pclss)
    (setq dist2 (1+ dist2)
    pt1 pt2
    )
    )
    (setq dist2 0
    ang0 (cdr ang0)
    ang1 (car ang0)
    dist0 (cdr dist0)
    dist1 (car dist0)
    cnt2 (1+ cnt2)
    )
    (if dist1
    (if (> dist1 3)
    (setq adist 1.0)
    (setq adist (* dist1 0.3333))
    )
    )
    )
    (command "_.pedit" "m" pclss "" "j" "" "")

    )
     
    T.Willey, Aug 5, 2004
    #18
  19. Michael Pape & Associates

    Tim Guest

    How about changing a POLYLINE into a LWPOLYLINE if 1 is picked and then run
    the routine..

    Tim


     
    Tim, Aug 5, 2004
    #19
  20. Michael Pape & Associates

    T.Willey Guest

    I would need the enitity code for one. I tried drawing different polylines, but they all came back as being "LWPOLYLINE", so if you list one (with entget) and post it, then I can see about doing that.

    Tim
     
    T.Willey, Aug 5, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.