Size REVCLOUD to AutoCAD Window Size

Size REVCLOUD to AutoCAD Window Size

nrz13
Advisor Advisor
1,472 Views
19 Replies
Message 1 of 20

Size REVCLOUD to AutoCAD Window Size

nrz13
Advisor
Advisor

I recently posted a request to scale the REVCLOUD differently based on whether I'm in model space or paper space, and it works well about 90% of the time.  But then I got to thinking:

Is there a way that the REVCLOUD can always be drawn at the same size based on my AutoCAD program window size?  That way I can control the size of the REVCLOUD as I go based on my zoom level and, if I'm thinking this through correctly, should work 100% of the time.  We all have the same size monitors and display resolutions in the office, so I think it should work for everyone that way.

So I'm looking for a LISP that does something like:  get program window size > multiply by a fixed REVCLOUD arc length value (just start with a guess and I can adjust this value to fit our needs before implementing) > draw REVCLOUD (freehand calligraphy).

Thanks in advance for any help.  My LISP knowledge is very basic.


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Accepted solutions (1)
1,473 Views
19 Replies
Replies (19)
Message 2 of 20

nrz13
Advisor
Advisor

I guess the LISP would also still need to know whether the user is in model space (including inside a viewport) vs. paper space to determine the correct scale factor.


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 3 of 20

Moshe-A
Mentor
Mentor

@nrz13 hi,

 

Revision Clouds are graphic annotative objects but AutoCAD never make them objects (like block, text, mtext, dimension, leader, hatch...) so if you want them annotative, maybe think of put them in a block but then what would you do with editing???

 

Moshe

 

0 Likes
Message 4 of 20

nrz13
Advisor
Advisor

They wouldn't be true annotative objects and that's okay.  I just want the arc length to be a function of the display size so it always draws the same size relative to my program window.


The relative size of what would be on my drawing would be based on my zoom level (e.g. if I zoom way in, the arc length will be really tiny around what I'm trying to cloud and if I zoom way out the arc length will be really large around what I'm clouding).


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 5 of 20

pendean
Community Legend
Community Legend
@nrz13 "zoom level" and "display size" are not truly defined setting in AutoCAD, you will need to be more specific, define that unknown way better than that I suspect.

What else in your files with your objects would you use instead as an arc-size marker?
0 Likes
Message 6 of 20

nrz13
Advisor
Advisor

@pendean
Zoom level is irrelevant in terms of the programming (it's just a way to quickly and easily control the use of what I was hoping to do after it has been programmed).  But, if I understand you correctly, there's no way for AutoCAD to determine its program window size.

There's too much other fluctuation from drawing to drawing, so if AutoCAD can't determine the size of it's program window, then I don't think my request will work and I'll have to stick with the version I currently have that sets different sizes in model space and paper space.


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 7 of 20

ronjonp
Mentor
Mentor

@nrz13 

Do you draw projects at a certain scale? I use the dimscale variable for our projects to determine how big or small my items need to be so that they are always the same plotted size. IE .. a 20 scale drawing and say .. setting the TEXTSIZE variable so that my text in modelspace will print in paperspace at 0.125. I know this is a bit old school with annotative objects now but it's worked for me for over 20 years.

 

(setvar 'textsize (* 0.125 (getvar 'dimscale)))
;; = 2.5 in modelspace and alway consistent .. same idea for revcloud arc length.

 

Just an idea.

0 Likes
Message 8 of 20

pendean
Community Legend
Community Legend

@nrz13 You'll want to ask Autodesk for this feature in future REVCLOUD versions then

pendean_0-1683144790862.png

 

Here is the link to that request page https://www.autodesk.com/company/contact-us/product-feedback

 

 

0 Likes
Message 9 of 20

ronjonp
Mentor
Mentor

@nrz13 The code from HERE will give you current viewport coordinates which then the distance can be found at whatever zoom level you're at. Multiply that by your magic number and it should work.

 

Something like this:

(defun c:rc (/ *error* lm:viewportextents e f ln n vals vars vp)
  ;; RJP » 2023-04-21
  ;; Creates a freehand calligraphy cloud on layer "Notes_Revisions" that is color 255,0,0
  ;; 
  ;; Viewport Extents  -  Lee Mac
  ;; Returns two WCS points describing the lower-left and
  ;; upper-right corners of the active viewport.
  (defun lm:viewportextents (/ c h v)
    (setq c (trans (getvar 'viewctr) 1 0)
	  h (/ (getvar 'viewsize) 2.0)
	  v (list (* h (apply '/ (getvar 'screensize))) h)
    )
    (list (mapcar '- c v) (mapcar '+ c v))
  )
  (defun *error* (msg)
    (if	(not (wcmatch msg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " msg))
    )
    (mapcar 'setvar vars vals)
    (princ)
  )
  (setq f (tblobjname "layer" (setq ln "Notes_Revisions")))
  ;; These are the scales you requested
  ;; If you use dimscale or something to differentiate scaled drawings it can be refined even more.
  (setq	n (if (> (getvar 'cvport) 1)
	    (progn (setq vp (lm:viewportextents)) (* 0.01 (distance (car vp) (cadr vp))))
	    0.125
	  )
  )
  (setq vars '(revcloudarcstyle revcloudarcvariance revcloudapproxarclen revcloudcreatemode))
  (setq vals (mapcar 'getvar vars))
  (mapcar 'setvar vars (list "Calligraphy" 0 n 0))
  (setq e (entlast))
  (initcommandversion)
  (command-s "_.revcloud")
  (or (equal e (setq e (entlast))) (entmod (append (entget e) (list (cons 8 ln)))))
  ;; Make layer RGB red if it did not exist already
  (or f (entmod (append (entget (tblobjname "layer" ln)) '((420 . 16711680)))))
  (mapcar 'setvar vars vals)
  (princ)
)
0 Likes
Message 10 of 20

nrz13
Advisor
Advisor

@ronjonp 
Thanks for helping me out with this again.  I debated following up in my other thread, but nixed the idea since it was technically a different request.  The LISP you provided is working great, but it has made me greedy for perfection now.  : )

It appears both of your posts require me to be in a viewport for it to work.  If the LISP you posted isn't supposed to work that way, then it's not working for me.  I changed the command to rcc for testing so my existing rc command wouldn't interfere with it.  Otherwise, I don't see it changing size (paper space is one size and model space is another, but that's it).

I'm going to try to explain what I'm expecting a bit better hopefully, because I'm not sure I've described it well enough yet.  If the physical dimensions of my display are 36" wide x 20" high (and the program window is maximized), I want the arc length to always be 1/2" relative to the physical dimensions of my display (as if I were drawing with a marker on my display).  Now, AutoCAD knows nothing about the physical dimensions of my monitor, but there is a resolution in pixels (if AutoCAD is able to "know" it's window size).  Thinking about this more, my display size is fixed and the "magic number" value is fixed, so it's going to return the same size arc length regardless of my zoom level, which means it'll be microscopic at certain zoom levels and not what I want.  So, contrary to what I said before, I think the zoom factor might need to be accounted for because AutoCAD doesn't know what 1/2" is relative to my display either.

Example of how I envision it working: 
I zoom in tightly on text in paper space, run the RC LISP, and it draws the arc lengths physically at 1/2" relative to my display (which means it's telling AutoCAD to use something like an 1/8" actual arc length).  I then switch to model space and cloud around a 300' long building and I'm really zoomed out to do this.  I still want the arc lengths to be 1/2" relative to my display, but in this case, the LISP would tell AutoCAD to use an actual arc length of something like 8'.

Possible process to code it:
Get screen resolution and multiply by current zoom factor and a constant I can adjust in the LISP; the resulting number is reported to the REVCLOUD command as an arc length value and then freehand drawing of the revision cloud can begin.

That's my end goal and if there's a better way to get there, that's fine with me.  I think the zoom factor will probably add another level of complexity and may not end up being practical in usage, but I don't know what other variable could be used.  When you're in model space, or in paper space (outside of a viewport), there's no scale to reference so I think that option is out.  The screen resolution may not be necessary either, but I'm trying to encompass situations where the program may not be maximized, or working on a different monitor.  Maybe that's asking too much.


@pendean 
Is that an annotative text option you shared?  Or else, what is that dialog from?


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 11 of 20

pendean
Community Legend
Community Legend

@nrz13 wrote:

Is that an annotative text option you shared?  Or else, what is that dialog from?


PTYPE system variable, about the only tool that has that feature https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-48AD2AE9-1EDE-4BF1-B3FA-F5B15225189E#:~:text=... 

Message 12 of 20

ronjonp
Mentor
Mentor

@nrz13 

IMO, I think you're overthinking this. If what you want is consistency I don't see how you accomplish that looking at resolutions and zoom levels?

 

Answer these questions:

Do you print your drawings to a scale?

If so how do you determine the scale ( only through a viewport, some variable )?

Why would anything in paperspace be a size other than 1:1?

 

Here's an example of my revcloud code. It can read scales through vieports and adjust so the visual arc length is the same regardless of viewport scale (ie .. gets smaller or larger depending on scale)

2023-05-04_09-01-50.gif

 

Maybe if you post a sample drawing with before and after I can help a bit further.

0 Likes
Message 13 of 20

nrz13
Advisor
Advisor

@ronjonp 

Our drawings are printed to scale (determined by viewport), but the revisions clouds can be in paper space or model space and model space is 1:1 (so very tiny arc lengths if it's being defined by a 1:1 size in paper space).

Further, even in paper space, I may zoom in to cloud a single line of notes (in paper space, not inside the viewport per your example), and then zoom back out to circle part of a plan or detail or whatever (also in paper space) and those arc lengths would ideally be larger.

Example drawing attached.  In the drawing, use cases for 1/8", 1/2", and 8' arc lengths are shown.  When I'm drawing them, they appear to be the roughly the same size relative to my screen because I'm zoomed way in to cloud the notes and zoomed way out to cloud in model space.


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 14 of 20

ronjonp
Mentor
Mentor
Accepted solution

@nrz13 

Give this a try.

The number you'll need to fiddle around with is here: (setq n (* 0.01 (distance (car vp) (cadr vp))))

 

 

(defun c:rcc (/ *error* lm:viewportextents e f ln n vals vars vp)
  ;; RJP » 2023-04-21
  ;; Creates a freehand calligraphy cloud on layer "Notes_Revisions" that is color 255,0,0
  ;; 
  ;; Viewport Extents  -  Lee Mac
  ;; Returns two WCS points describing the lower-left and
  ;; upper-right corners of the active viewport.
  (defun lm:viewportextents (/ c h v)
    (setq c (trans (getvar 'viewctr) 1 0)
	  h (/ (getvar 'viewsize) 2.0)
	  v (list (* h (apply '/ (getvar 'screensize))) h)
    )
    (list (mapcar '- c v) (mapcar '+ c v))
  )
  (defun *error* (msg)
    (if	(not (wcmatch msg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " msg))
    )
    (mapcar 'setvar vars vals)
    (princ)
  )
  (setq f (tblobjname "layer" (setq ln "Notes_Revisions")))
  ;; These are the scales you requested
  ;; If you use dimscale or something to differentiate scaled drawings it can be refined even more.
  (setq vp (lm:viewportextents))
  (setq n (* 0.01 (distance (car vp) (cadr vp))))
  (setq vars '(revcloudarcstyle revcloudarcvariance revcloudapproxarclen revcloudcreatemode))
  (setq vals (mapcar 'getvar vars))
  (mapcar 'setvar vars (list "Calligraphy" 0 n 0))
  (setq e (entlast))
  (initcommandversion)
  (command-s "_.revcloud")
  (or (equal e (setq e (entlast))) (entmod (append (entget e) (list (cons 8 ln)))))
  ;; Make layer RGB red if it did not exist already
  (or f (entmod (append (entget (tblobjname "layer" ln)) '((420 . 16711680)))))
  (mapcar 'setvar vars vals)
  (princ)
)

 

 

 

 

Message 15 of 20

nrz13
Advisor
Advisor

@ronjonp 

Thank you!  That's working just like I was expecting in the 5 minutes I spent testing it so far.  It works perfectly in paper space and perfectly in model space, but doesn't adjust when inside of a viewport in paper space.  This is a low use case for us, and can still manually be adjusted, so if adding support for that would compromise the other two conditions, we're best leaving it as is.

I'll see how it goes using it over the new several days, but it looks like we're there.  I raised the scale factor ("magic number") to 0.02 instead of 0.01 and I have a feeling I may ultimately land somewhere between those two values, which is to say you pegged it well.


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 16 of 20

ronjonp
Mentor
Mentor

@nrz13 Glad we got it sorted 👍. As far as the floating viewport situation, what would you expect? Quick test here and it works as intended. The blue cloud was drawn in floating modelspace at the same zoom level as the red cloud drawn in paperspace,

image.png

0 Likes
Message 17 of 20

nrz13
Advisor
Advisor

If you zoom in and out inside the active viewport, it stays the same size, rather than adjusting to the zoom level as it does in paper space and model space.  So what I'd want there is for it to work the same way as it does in paper space and model space.  If I'm inside an active viewport window and I zoom way in, the arc length reported to AutoCAD would ideally be smaller and then if I zoom back out, it would be larger.  Does that make sense?


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 18 of 20

ronjonp
Mentor
Mentor

@nrz13 The code looks at zoom distance corner to corner in the active window, so currently as it's written not possible in a locked viewport. Unlock a viewport and try it.

0 Likes
Message 19 of 20

nrz13
Advisor
Advisor

It does work in an unlocked viewport, but we would also never zoom in inside an unlocked viewport because it would lose the scale and positioning within the viewport.  So it sounds like your solution above is the best we can technically do, which gets us ≈99% there for our use cases and is leagues better than the default AutoCAD command (and also better than the solution you helped me with a couple of weeks ago).

Thanks again for sticking with this and for all your help!


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 20 of 20

ronjonp
Mentor
Mentor

@nrz13 wrote:

It does work in an unlocked viewport, but we would also never zoom in inside an unlocked viewport because it would lose the scale and positioning within the viewport.  So it sounds like your solution above is the best we can technically do, which gets us ≈99% there for our use cases and is leagues better than the default AutoCAD command (and also better than the solution you helped me with a couple of weeks ago).

Thanks again for sticking with this and for all your help!


Glad to help out :). It sounds like the other 1% to make it 'perfect' is to not revcloud in floating modelspace. 😎