Jump to content

Recommended Posts

Posted

hello:

I use this routine to know the scale and then get inside

The problem is that after I return to paper space

and I try to select another window and it selects the first one

can that be solved?

 

help please.

 

defun c:test (/)
  

  ;inicio de la rutina
 (setq old_err *error*)(defun *error* ( a / )(princ "") (setq *error* old_err)(princ))
(setvar "cmdecho" 0) 
(if (and (setq EntVP (car (entsel "\Seleccione VIEWPORT: "))) 
(= (cdr (assoc 0 (entget EntVP))) "VIEWPORT")) 
(progn 
(setq EscVP (vla-get-CustomScale (vlax-ename->vla-object EntVP))) 
(setq StrScale (rtos (/ 1 EscVP) 2 2) 

(Prompt (strcat "\nLa escala de La Ventana es 1/" StrScale)) 

)
(setq inv-vps (/ 1 EscVP))
(setvar "cmdecho" 1)
(terpri)
(princ EscVP)
(terpri)
(princ StrScale)
(terpri)
(command "_.MSPACE")

(princ) 

 

 

Posted (edited)

Try this .. you need to get the viewport ID ( DXF code 69 ).

(defun c:test (/ *error* entvp escvp inv-vps old_err strscale) ;inicio de la rutina
  ;;(setq old_err *error*)
  ;;(defun *error* (a /) (princ "") (setq *error* old_err) (princ))
  ;;(setvar "cmdecho" 0)
  (if (and (setq entvp (car (entsel "\Seleccione VIEWPORT: ")))
	   (= (cdr (assoc 0 (entget entvp))) "VIEWPORT")
      )
    (progn (setq escvp (vla-get-customscale (vlax-ename->vla-object entvp)))
	   (setq strscale (rtos (/ 1 escvp) 2 2))
	   (prompt (strcat "\nLa escala de La Ventana es 1/" strscale))
	   ;; You need to set the viewport ID after going into floating modelspace
	   (command "_.MSPACE")
	   (setvar 'cvport (cdr (assoc 69 (entget entvp))))
    )
  )
  (setq inv-vps (/ 1 escvp))
  ;;(setvar "cmdecho" 1)
  (terpri)
  (princ escvp)
  (terpri)
  (princ strscale)
  (terpri)
  (princ)
)

 

BTW .. the code you posted above is missing parenthesis so not sure how you're using it? 🤔

Edited by ronjonp
  • Like 1
  • Funny 1
Posted

 

thanks that was very helpful

Posted

How Can I change  the current viewport while in paper space?

Posted

How can this value be changed?

 

 

image.png.f7cbc15baa58e3151348d6abcef57a75.png

Posted
46 minutes ago, leonucadomi said:

How Can I change  the current viewport while in paper space?

I put a comment in the code:
 

Quote

;; You need to set the viewport ID after going into floating modelspace

 

What are you trying to accomplish?

Posted

Try this.

 

(defun c:test (/ ss escvp strscale)
  (setvar 'cvport 1)  ;goes into PAPERSPACE automatically
  (if (setq ss (ssget "_+.:E:S" '((0 . "VIEWPORT"))))  ;only allows you to pick a viewport
    (progn
      (setq escvp (vla-get-customscale (setq vp (vlax-ename->vla-object (ssname SS 0))))
            strscale (rtos (/ 1 escvp) 2 2)
      )
      ;; You need to set the viewport ID after going into floating modelspace
      (setvar 'cvport (cdr (assoc 69 (entget (ssname SS 0)))))
      (prompt (strcat "\nLa escala de La Ventana es 1/" strscale " = " (rtos escvp 2)))
    )
  )
  (princ)
)

 

  • Like 1
  • Thanks 1

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