Revcloud Lisp that sets width, layer, and arc length

Revcloud Lisp that sets width, layer, and arc length

PerryLackowski
Advocate Advocate
3,750 Views
10 Replies
Message 1 of 11

Revcloud Lisp that sets width, layer, and arc length

PerryLackowski
Advocate
Advocate

As the title suggests, I'm looking to create a lisp that can generate a revision cloud (with 1/8" arc length) out of an existing polyline, and then modify it's width (1/64") and layer ("REVISION"). Trouble is, I'm not sure how to select the new cloud after the REVCLOUD function ends. Here's all I've got so far. I've included the "Reverse direction" prompt because it appears that running the revcloud command this way prevents the prompt from appearing on its own.

 

(defun c:rvc (/ )
(command "revcloud" "a" "1/8" "1/8" "o" pause)
(prompt "\nReverse direction [Yes/No] <No>:")
(command pause)
;need to select the revcloud here
)
0 Likes
Accepted solutions (2)
3,751 Views
10 Replies
Replies (10)
Message 2 of 11

ВeekeeCZ
Consultant
Consultant
(defun c:rvc (/ )
  (command "revcloud" "a" "1/8" "1/8" "o" pause)
  (prompt "\nReverse direction [Yes/No] <No>:")
  (command pause)
  (command "_.chprop" "_last" "" "_Layer" "0" "")
  (princ)
  )

 

Use the "_last" option of the selection as it is the last entity added to the database.

Edit: Sorry for my confusion.

0 Likes
Message 3 of 11

PerryLackowski
Advocate
Advocate

Thanks, that's what I was looking for! I tried to repeat what you did with the pedit command to set the polyline width, but I'm getting an Unknown command "_Width" error... Is there something wrong with my syntax? I tried with and without the quotes around the 0.015625 but that didn't make a difference.

 

 

(defun c:rvc (/ )
	(command "revcloud" "a" "1/8" "1/8" "o" pause)
	(prompt "\nReverse direction [Yes/No] <No>:")
	(command pause)
	
	(command "_.chprop" "_last" "" "_Layer" "REVISION" "")
	
	(command "_.pedit" "_last" "" "_Width" 0.015625 "")
	
	(princ)
)

 

 

 

0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

@PerryLackowski wrote:

.... a lisp that can generate a revision cloud ... out of an existing polyline, and then modify it's width ... and layer .... I'm not sure how to select the new cloud after the REVCLOUD function ends. .... I've included the "Reverse direction" prompt because it appears that running the revcloud command this way prevents the prompt from appearing on its own.


 

For me [Acad2019], it does  prompt for the reverse-direction choice when in a (command) function.  Do you have command-echoing turned off [CMDECHO System Variable]?

 

The other modifications can be applied to the last object -- (entlast) -- in a couple of ways.  This works for me:

(defun C:RVC (/ rcdata)
  (command "_.revcloud" "_arc" "1/8" "1/8" "_object" pause pause)
  (setq
    rcdata (entget (entlast))
    rcdata (append rcdata '((43 . 0.015625))); global width
    rcdata (subst '(8 . "REVISION") (assoc 8 rcdata) rcdata); Layer
  ); setq
  (entmod rcdata); update changes
  (princ)
); defun

 

Tacking the global-width entry onto the end  of the entity data list will win out over prior width entries, and override any existing such global-with entry if present, or any variability of width, in the source Polyline.

 

One interesting benefit of doing it with (subst)/(entmod) methods with entity data, rather than the other approaches using CHPROP or VLA-object-based methods, is that it doesn't matter whether the Layer exists in the drawing.  If it doesn't, the above will make it, though it will have default properties [e.g. Color 7, Continuous linetype, etc.], so if you want specific properties, be sure the Layer exists.  [You could also build the making of it with the required properties into the routine.]

Kent Cooper, AIA
0 Likes
Message 5 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

@PerryLackowski wrote:

Thanks, that's what I was looking for! I tried to repeat what you did with the pedit command to set the polyline width, but I'm getting an Unknown command "_Width" error... Is there something wrong with my syntax? I tried with and without the quotes around the 0.015625 but that didn't make a difference.

 

 

(defun c:rvc (/ )
	(command "revcloud" "a" "1/8" "1/8" "o" pause)
	(prompt "\nReverse direction [Yes/No] <No>:")
	(command pause)
	
	(command "_.chprop" "_last" "" "_Layer" "REVISION" "")
	
	(command "_.pedit" "_last" "" "_Width" 0.015625 "")
	
	(princ)
)

 

 

 


 

Remove the red ones. PEDIT accepts a single entity only unless you choose the Multiple option.

0 Likes
Message 6 of 11

PerryLackowski
Advocate
Advocate

This is invaluable, thank you!

 

One final thing, and I realize this is diverging from the original topic: I have projects that use two different revision layers. Some use "REVISION" and some use "G-REVS". Could I check for the existence of these layers, and use them if they are already in the drawing? If not, just leave on the current layer?

0 Likes
Message 7 of 11

Kent1Cooper
Consultant
Consultant

@PerryLackowski wrote:

.... I have projects that use two different revision layers. Some use "REVISION" and some use "G-REVS". Could I check for the existence of these layers, and use them if they are already in the drawing? If not, just leave on the current layer?


 

That shouldn't be difficult.  Would the Layer names ever both  exist in the same drawing?  If so, how should it choose which to use?

Kent Cooper, AIA
0 Likes
Message 8 of 11

PerryLackowski
Advocate
Advocate

They won't, but if that somehow happened accidently I'd prefer it stay on the current layer.

0 Likes
Message 9 of 11

Kent1Cooper
Consultant
Consultant

@PerryLackowski wrote:

They won't, but if that somehow happened accidently I'd prefer it stay on the current layer.


 

Try this:

(defun C:RVC (/ rcdata)
  (command "_.revcloud" "_arc" "1/8" "1/8" "_object" pause pause)
  (setq
    rcdata (entget (entlast))
    rcdata (append rcdata '((43 . 0.015625))); global width
  ); setq
  (cond
    ((and (tblsearch "layer" "REVISION") (tblsearch "layer" "G-REVS")))
      ;; both exist -- do nothing
    ((tblsearch "layer" "REVISION")
      (setq rcdata (subst '(8 . "REVISION") (assoc 8 rcdata) rcdata))
    ); REVISION-exists condition
    ((tblsearch "layer" "G-REVS")
      (setq rcdata (subst '(8 . "G-REVS") (assoc 8 rcdata) rcdata))
    ); G-REVS-exists condition
  ); cond [no none-of-the-above condition if neither Layer exists]
  (entmod rcdata); update change(s)
  (princ)
); defun
Kent Cooper, AIA
0 Likes
Message 10 of 11

PerryLackowski
Advocate
Advocate

Works like a charm! Thank you both!

0 Likes
Message 11 of 11

fkellogg
Advocate
Advocate

I use a tool palette for this. do this:

Create a revcloud to your liking, with arc lengths, arc style, layer, etc the way you want it.

Select the revcloud and copy to clipboard.

Paste the revcloud to a tool palette.

Right click on it, to check the Properties settings.

The [Arc length/Object/Rectangular/Polygonal/Freehand/Style/Modify] options are not available, as they are stored in the registry. Other properties may be set to you liking.

From the tool palette, click the tool. You will see in the command line all the Options, but from there you can simply click two points and get a rectangular revcloud. OR, hit enter, and click any polyline. Either way, the revcloud will be drawn.

 

The good part of this is that you can change your preferences on the fly, without having to go in and edit lisp code. And, you can have two tools; one for one layer, and another for the other layer. 

 

0 Likes