Help with Viewres routine

Help with Viewres routine

msarqui
Collaborator Collaborator
957 Views
8 Replies
Message 1 of 9

Help with Viewres routine

msarqui
Collaborator
Collaborator

Hi all!

 

Could someone help me please?

I am trying to made a routine that will change VIEWRES on the startup, if it is different from what I want. If not, the routine does nothing. But it seems that the routine is changing always...

 

(defun CHVRS ()
(if
 (/= (cdr (assoc 72 (dictsearch (namedobjdict) "AcDbViewportTableRecord"))) 100) ;I am not sure here, I made this after some cad forums research...
 (progn
 (command "._viewres" "Y" 100)
 (princ "\n  ** Viewres changed to 100 **")
 );progn
 (princ "\n  ** Viewres is already 100 **")
);if
(princ)
);defun

(CHVRS)

 

Thanks!

0 Likes
Accepted solutions (1)
958 Views
8 Replies
Replies (8)
Message 2 of 9

hmsilva
Mentor
Mentor

Hi Marcelo,

 

possibly would use something like this (untested)

 

(vl-load-com)
(defun CHVRS (/ acdoc acvp)
  (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (cond ((= 1 (getvar 'TILEMODE))
         (if
           (/= (vla-get-arcsmoothness (setq acvp (vla-get-activeviewport acdoc))) 100)
            (progn
              (vla-put-arcsmoothness acvp 100)
              (vla-put-activeviewport acdoc acvp)
              (princ "\n  ** Viewres changed to 100 **")
            )
            (princ "\n  ** Viewres is already 100 **")
         )
        )
        (T
         (if
           (/= (vla-get-arcsmoothness (setq acvp (vla-get-activepviewport acdoc))) 100)
            (progn
              (vla-put-arcsmoothness acvp 100)
              (vla-put-activepviewport acdoc acvp)
              (princ "\n  ** Viewres changed to 100 **")
            )
            (princ "\n  ** Viewres is already 100 **")
         )
        )
  )
  (princ)
)
(CHVRS)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 9

msarqui
Collaborator
Collaborator
Testing...
0 Likes
Message 4 of 9

msarqui
Collaborator
Collaborator

Hi Henrique,

 

Thanks for the routine. Well tested and it does change the VIEWRES on the startup as I asked.

Only one small detail : it always shows this message "Viewres is already 100". Is this because you did two times the same process in the routine? Like a double check?

 

Thanks again.

Marcelo

0 Likes
Message 5 of 9

hmsilva
Mentor
Mentor

@msarqui wrote:

Hi Henrique,

 

Thanks for the routine. Well tested and it does change the VIEWRES on the startup as I asked.

Only one small detail : it always shows this message "Viewres is already 100". Is this because you did two times the same process in the routine? Like a double check?

 

Thanks again.

Marcelo


You're welcome, Marcelo!

The command line message "Viewres is already 100", will show only if the test expression returns T...

I wrote the code keeping your message structure.
If you don't want to get the messages, just remove or comment the messages...

 

I didn't use two times the same process, the first 'activeviewport' will test if model is the active space, the second 'activePviewport' if paper space ou floating model space.


Henrique

EESignature

0 Likes
Message 6 of 9

msarqui
Collaborator
Collaborator

my mind is spinning...

 


@hmsilva wrote:

 

(vl-load-com)
(defun CHVRS (/ acdoc acvp)
  (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (cond
((= 1 (getvar 'TILEMODE)) This will test if model is the active space. I am OK here. (if (/= (vla-get-arcsmoothness (setq acvp (vla-get-activeviewport acdoc))) 100) (progn (vla-put-arcsmoothness acvp 100) (vla-put-activeviewport acdoc acvp) (princ "\n ** Viewres changed to 100 **") ) (princ "\n ** Viewres is already 100 **") ) ) (T This will test if paper space or floating model space? How? I can't see... :( (if (/= (vla-get-arcsmoothness (setq acvp (vla-get-activepviewport acdoc))) 100) (progn (vla-put-arcsmoothness acvp 100) (vla-put-activepviewport acdoc acvp) (princ "\n ** Viewres changed to 100 **") ) (princ "\n ** Viewres is already 100 **") ) ) ) (princ) ) (CHVRS)

 


Sorry for the inconvenience. 

I would just understand. 🙂

0 Likes
Message 7 of 9

hmsilva
Mentor
Mentor
Accepted solution

Marcelo,

 

in the first conditional test (= 1 (getvar 'TILEMODE), if returns true, it means that the active space is 'model space', if this condition is not true, it means the active space is 'paper' or 'floating model space', and for both spaces, we'll have to get/set the 'arcsmoothness' property from the 'activepviewport' object...

 

See if in this way is easier to understand

(defun CHVRS (/ acdoc acvp)
  (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (if (= 1 (getvar 'TILEMODE))
    (if (/= (vla-get-arcsmoothness (setq acvp (vla-get-activeviewport acdoc))) 100)
      (progn
        (vla-put-arcsmoothness acvp 100)
        (vla-put-activeviewport acdoc acvp)
        (princ "\n  ** Viewres changed to 100 **")
      )
      (princ "\n  ** Viewres is already 100 **")
    )
    (if (/= (vla-get-arcsmoothness (setq acvp (vla-get-activepviewport acdoc))) 100)
      (progn
        (vla-put-arcsmoothness acvp 100)
        (vla-put-activepviewport acdoc acvp)
        (princ "\n  ** Viewres changed to 100 **")
      )
      (princ "\n  ** Viewres is already 100 **")
    )
  )
  (princ)
)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 8 of 9

msarqui
Collaborator
Collaborator
Yes, I see. And now I realised that it was pretty obvious... 🙂
I am really glad for your help!
0 Likes
Message 9 of 9

hmsilva
Mentor
Mentor

You're welcome, Marcelo!
Glad I could help

Henrique

EESignature

0 Likes