Jump to content

Recommended Posts

Posted (edited)

I have a simple layout tab which contains a single viewport. In this viewport I want to zoom around an ole object which was pasted into model space based on some other input. The size of this ole object (copied and pasted from different Excel files) will vary in size. Thus the need to zoom it in the viewport.

 

;activate the layout tab
(setvar "CTAB" "8x11BOM")

..go into model space inside the viewport on this layout
..zoom Object

 

My searches for help keep coming up with selection sets and layout tabs with multiple viewports.

Edited by Bill Tillman
Posted

After much fruitless searching I came up with something that Massau had published here some time ago. And though that code was not what I needed exactly I saw something in there which clicked. At first I thought, it couldn't be that easy...and perhaps it's not. But with only one viewport on the layout, and that is all there will ever be, it works.

 

(command "._PASTECLIP" '(-270.0 0.0))
(setq obj_BOM (entlast))

(setvar 'CTAB "my_layout_tab")
(command "._MSPACE")
(command "._ZOOM" "O" obj_BOM" "")
(command "._PSPACE")
(command "._ZOOM" "E")

 

This works if there is something in the clipboard and in this case there always will be. And because there is only on viewport to deal with. Apparently, the mspace command will work with the last viewport placed in the layout tab. I tested with more than one and it always grabbed the last one created. Now for a new exercise to figure out how to grab a particular viewport.

Posted

Maybe this code will help you to grab correct viewport :

 

(defun c:cyclvp ( / ss i entvp )
 (setvar 'tilemode 0)
 (command "_.mspace")
 (setq ss (ssget "_X" (list (cons 0 "VIEWPORT") (cons 410 (getvar 'ctab)))))
 (setq i (- (sslength ss) 1))
 (while (eq (getstring "\nENTER to cycle - any key+ENTER to exit : ") "")
   (if (eq (setq i (1- i)) -1) (setq i (- (sslength ss) 2)))
   (setq entvp (ssname ss i))
   (setvar 'cvport (cdr (assoc 69 (entget entvp))))
 )
 (princ)
)

 

M.R.

Posted

Thanks very much sir. I wanted to post a link to the earlier post I read by Massau but my computer required a reboot and I lost the link. Your code is very much like that one. My situation is somewhat different in that no user input is allowed. That's what always makes my questions more complicated than normal. Still, it would be nice to come up with a bit of code which would grab that one and only viewport for operations like locking it. That's the next step. This actually solved two problems for me. First it allowed me to enter the title block data onto these layouts which contain the BOM's for these assemblies. And because these BOM's are actually OLE objects pasted in from Excel there are very few of them that are the same size. Getting this done now means I can lock the viewports because after the zoom "O" is completed, the BOM actually fits on the page very nicely. The users are pleased any way. But the next complaint or demand for new features has already made it's way into my inbox.

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