Jump to content

Recommended Posts

Posted

Hi,

I need to get the coordinates of the video limits of a drawing (not the drawing extent). I have tried getting "LIMMIN" and "LIMMAX" variable, but is not the result that I need.

I need these points because I need to know the limits of the wmf exported. Now I can only read them -by-hand- with the "status" command

Thanks

Posted

Thanks for you reply, but I haven't found Vpmax/Vpmin variables. I'm using ACad2008.

Posted

I have tried, but VSMin / VSMax are not the values Im looking for. Any other guess?

Posted

Now I have understood how to calculate the Y coordinates of the LL/UR corners of the screen view (=VIEWCTRy +(-) VIEWSIZE /2) . But how to get the Height/Width ratio of the screen to calculate the X coordinates using VSMin / VSMax? Sorry, but I'm not so smart with view and viewport.

Posted

I tried this, it works sometimes, not always. What I've found is that using Vsmax/Vsmin doesn't always give the ratio of the screen size

(defun test ()
 (setq vmax (getvar "vsmax")
   vmin (getvar "vsmin")
   vctr (getvar "viewctr")
   vhgt (getvar "viewsize");view height
   vrat (/ (abs(- (car vmin)(car vmax))) (abs (- (cadr vmin)(cadr vmax)))); view width/height ratio
   vwid (* vrat vhgt);view width
   vll (list (- (car vctr) (/ vwid 2)) (- (cadr vctr) (/ vhgt 2))); Lower left coordinates
   vur (list (+ (car vctr) (/ vwid 2))(+ (cadr vctr) (/ vhgt 2))); Upper right coordinates
   )
 )

Posted
I tried this, it works sometimes, not always. What I've found is that using Vsmax/Vsmin doesn't always give the ratio of the screen size

 

I've had that same problem in the past.

 

I use a bit different approach:

[b][color=BLACK]([/color][/b]defun c:scrsize [b][color=FUCHSIA]([/color][/b]/ tdef c x y ll ur[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.VIEW"[/color] [color=#2f4f4f]"_Save"[/color] [color=#2f4f4f]"TMP"[/color][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq tdef [b][color=NAVY]([/color][/b]tblsearch [color=#2f4f4f]"VIEW"[/color] [color=#2f4f4f]"TMP"[/color][b][color=NAVY])[/color][/b]
          c [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 10 tdef[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
          x [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 41 tdef[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
          y [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 40 tdef[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
         ll [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]- [b][color=GREEN]([/color][/b]car  c[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* x 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
                  [b][color=MAROON]([/color][/b]- [b][color=GREEN]([/color][/b]cadr c[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* y 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
         ur [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]car  c[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* x 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
                  [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]cadr c[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* y 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]list ll ur[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

Crude, but then acad can be crude as well. -David

Posted

Nice David... as crude as you may think it is, at least it gives accurate/consistent results. I would have never thought of saving a View and using tblsearch.

Posted

Sometimes crude works for me! Forcing ACAD to do the work is also my favorite things to do.

 

Another way to calculate the x:

(* (getvar "VIEWSIZE) (/ (car (getvar "SCCRENSIZE"))
                        (cadr (getvar "SCREESIZE"))))

 

This one is a little better because it should be a bit smaller than the actual size. -David

Posted

from David Bethel's example above, this should work

(setq vctr (getvar "viewctr")
   vhgt (getvar "viewsize");view height
   vrat (/ (car (getvar "screensize"))(cadr (getvar "screensize")));view width/height ratio
   vwid (* vrat vhgt);view width
   vll (list (- (car vctr) (/ vwid 2)) (- (cadr vctr) (/ vhgt 2))); Lower left coordinates
   vur (list (+ (car vctr) (/ vwid 2))(+ (cadr vctr) (/ vhgt 2))); Upper right coordinates
   )

I feel a bit sheepish not knowing of the sysvar Screensize; never had an occasion to use it. Ya learn something new every day...

Posted

Wow, thanks for your answers.

The last method leave a little error on the x coordinate.

My purpose is to draw localized point on the WMF exported file and I need to be 100% precise. So I would like to read the view data. The problem is that I use VB with Autocad 2008 and I don't know how to get the "current view" object, or how to save a new view with the current dimensions.

Dim v As Common.AcadView
v = acadCurrentDoc.Views.Add("TMP")
MsgBox(v.Width & ", " & v.Height)

With this code v doesn't contain the W&H of the current view.

Can you give me more help?

Thanks

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...