Jump to content

PLINE Cloud?


AQucsaiJr

Recommended Posts

I found a simple cloud lisp command that Fixo posted that drew a rectangle and then converted it to a cloud. Can this same basic lisp be adjusted to use a PLINE rather than a rectangle?

 

 

 

; Library pr.#
; written by Fatty T.O.H. (c)2005
; all rights removed
(defun C:CLD (/ aleng p1 p2 )
(setq p1 (getpoint "\nPick firs corner of rectangle: \n")
     p2 (getcorner p1 "\nPick opposite corner: \n")
     aleng (getdist "\nEnter arc length for cloud : "))
(command "_.rectangle" p1 p2)
(command "_.revcloud" "_A" aleng "" "_O" (entlast) "")
(princ)
)
(prompt "\n\t\t***   Type CLD to execute   *** \n")
(princ)
;;; TesT : (C:CLD)

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    12

  • AQucsaiJr

    9

  • alanjt

    3

  • ReMark

    2

Top Posters In This Topic

If you have the pline drawn, try the Revcloud > Object option. If you really want the lisp edited, try replacing the (command "_.rectangle... with

(command "_.pline")
(while (= 1 (getvar "cmdactive"))
   (command pause))

you might want to get rid of the getpoint/getcorner

Link to comment
Share on other sites

I don't see why it is necessary. The RevCloud command has an option called Object. Create the outline of what you want the RevCloud to encompass with a polyline. Use the Object option of RevCloud and select the polyline. It is instantly turned into a RevCloud. Done.

 

Why re-invent the wheel?

Link to comment
Share on other sites

I will try these links and also changing the LISP I already have.

 

The reason I am looking for this is because currently I do draw a PLINE around what I need to cloud and use the object command in the cloud command to change the PLINE to a cloud. I also have to place the cloud on a certain layer after it is created, which I could add to the LISP. But it Isn't that this process is hard to do a couple times in a drawing, it is that I have to do this process several times in each of the 100+ drawings in a single project. One of the companies we work with has a command that does this but it uses visual basic and does not work on the ACAD we use. But I think I can make this work.

Link to comment
Share on other sites

As a more robust routine:

 

(defun c:cld (/ *error* cldlay ol)
 (vl-load-com)

 (setq cldlay "CLOUD_LAYER") ;; <<-- Layer for Cloud

 (defun *error* (msg)
   (and ol (setvar "CLAYER" ol))
   (if doc (vla-EndUndoMark doc))
   (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
     (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq doc (vla-get-ActiveDocument
             (vlax-get-acad-object)))
 (vla-StartUndoMark doc)
 
 (or (tblsearch "LAYER" cldlay)
     (vla-add (vla-get-layers doc) cldlay))  

 (setq ol (getvar "CLAYER"))
 (command "_.pline")
 (while (= 1 (logand 1 (getvar "CMDACTIVE")))
   (command pause))
 (setvar "CLAYER" cldlay)
 (command "_.revcloud" "_O" (entlast) pause)
 
 (setvar "CLAYER" ol)
 (vla-EndUndoMark doc)
 (princ))

Link to comment
Share on other sites

Great... Both adding that line to the lisp I had and this new LISP Lee has provided work great. I would like to add a little something to Lee's LISP though, how would I add settings to the layer that is being created Lee? The layer we place our clouds on needs to be blue or green, depending on its purpose.

Link to comment
Share on other sites

No... I like how you have it written. There should be a layer in the drawing called C-Cloud and the color of that layer should be blue. If it is not there than your LISP will create it but I can't figure out how to make the color blue.

Link to comment
Share on other sites

Like this:

 

(defun c:cld (/ *error* cldlay cCol ol)
 (vl-load-com)

 (setq cldlay "C-CLOUD" cCol 5) ;; <<-- Layer/Col for Cloud

 (defun *error* (msg)
   (and ol (setvar "CLAYER" ol))
   (if doc (vla-EndUndoMark doc))
   (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
     (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq doc (vla-get-ActiveDocument
             (vlax-get-acad-object)))
 (vla-StartUndoMark doc)
 
 (or (tblsearch "LAYER" cldlay)
     (vla-put-color
       (vla-add
         (vla-get-layers doc) cldlay) 5))

 (setq ol (getvar "CLAYER"))
 (command "_.pline")
 (while (= 1 (logand 1 (getvar "CMDACTIVE")))
   (command pause))
 (setvar "CLAYER" cldlay)
 (command "_.revcloud" "_O" (entlast) pause)
 
 (setvar "CLAYER" ol)
 (vla-EndUndoMark doc)
 (princ))

Link to comment
Share on other sites

I think you have the right idea with the forced color, however it is not working for my. The C-CLOUD layer still defaults to white. Unless I am supposed to change the number to the blue?

Link to comment
Share on other sites

I think you have the right idea with the forced color, however it is not working for my. The C-CLOUD layer still defaults to white. Unless I am supposed to change the number to the blue?

 

I have just changed the code such that if the layer does not exist, the created layer will be blue - I assumed that the layer you had was blue.

Link to comment
Share on other sites

This should work either way :)

 

(defun c:cld (/ *error* cldlay cCol ol)
 (vl-load-com)

 (setq cldlay "C-CLOUD" cCol 5) ;; <<-- Layer/Col for Cloud

 (defun *error* (msg)
   (and ol (setvar "CLAYER" ol))
   (if doc (vla-EndUndoMark doc))
   (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
     (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq doc (vla-get-ActiveDocument
             (vlax-get-acad-object)))
 (vla-StartUndoMark doc)
 
 (or (tblsearch "LAYER" cldlay)
     (vla-add (vla-get-layers doc) cldlay))
 (vla-put-color
   (vla-item
     (vla-get-layers doc) cldlay) cCol)

 (setq ol (getvar "CLAYER"))
 (command "_.pline")
 (while (= 1 (logand 1 (getvar "CMDACTIVE")))
   (command pause))
 (setvar "CLAYER" cldlay)
 (command "_.revcloud" "_O" (entlast) pause)
 
 (setvar "CLAYER" ol)
 (vla-EndUndoMark doc)
 (princ))

Link to comment
Share on other sites

Lee, for your error handler, if you will check to see the msg variable has been filled, you can just call (*error* nil) and the end of a routine to run all closing procedures. Just an easy way to eliminate extra coding.

 

Here's mine (I finally decided to adapt the wcmatch way. I remember the post @ theswamp, but I can't remember who did it.)

 

  (defun *error* (#Message)
   (and #Message
        (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))
        (princ (strcat "\nError: " #Message))
   ) ;_ and
 ) ;_ defun

Link to comment
Share on other sites

Lee, for your error handler, if you will check to see the msg variable has been filled, you can just call (*error* nil) and the end of a routine to run all closing procedures. Just an easy way to eliminate extra coding.

 

Here's mine (I finally decided to adapt the wcmatch way. I remember the post @ theswamp, but I can't remember who did it.)

 

  (defun *error* (#Message)
   (and #Message
        (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))
        (princ (strcat "\nError: " #Message))
   ) ;_ and
 ) ;_ defun

 

Yeah, I've seen that before, CAB used to use it a lot: (*error* nil) But imo, I don't like calling an error function unless there's an error.. maybe its just me o:)

 

PS> wcmatch accredited to Joe Burke :)

Link to comment
Share on other sites

I have been reading a learning a little more each week on building LISP, but I can't figure this out, why should you have the error function in there? In reference to this cloud LISP, what would cause an error?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...