Your process sounds like what I'm after. I just need to know how to do it
in VBA. The lisp command vports returns a list of values representing the
'location' of each visible viewport window. The first in the list is the
current window:
"The current viewport's descriptor is always first in the list. In the
previous example, viewport number 5 is the current viewport."
Does anyone know how to get these 'descriptors' in VBA?
Bobby Jones wrote in message
news:7CE0006E16B9116392FC627C2B62EF74@in.WebX.maYIadrTaRb...
> Keith, My understanding of sharing info between VBA and lisp is limited,
so
> maybe someone could help us with that part, but I'll break down exactly
> what's going on in these routines. First of all these routines are
> utilities and therefore they do not retrieve the viewport objects
> themselves, they are passed from another function. The first line of
> getViewData:
>
> (defun getViewData (vlaObj / entlst)
> defines the 'procedure' getViewData and sets the variable vlaObj, local to
> the procedure, as an argument that will be passed to the procedure and
sets
> the scope of the variable entlst as local to the procedure. The procedure
> expects a valid psViewport object to be passed to it and it will be
assigned
> to the vlaObj variable.
>
> The next line converts the viewport object into an entity name that lisp
> functions will understand, gets the DXF association list from the entity,
> and assigns that information to the variable entlst
> (setq entlst (entget (vlax-vla-object->ename vlaObj)))
>
> The next function takes the dxf association list of the viewport and
> converts it into an association list that matches the association list of
a
> view entity with the same view as the viewport. It doesn't create the
view,
> it just gathers the information that the view would contain if it existed.
> (mapcar '(lambda (x y) (cons x (cdr (assoc y entlst))))
> '(40 10 11 12 42 43 44 50 110 111 112 79 146)
> '(45 12 16 17 42 43 44 51 110 111 112 79 146)
> ) ;_ end of mapcar
>
> All lisp functions, or almost all, return a value. The getViewData
function
> returns the newly created data list of our imaginary view. The putView
> function takes that data and applies it to another psViewport object so
that
> it changes the view to match. So you would call the putView something
like
> this:
>
> (putView vpObjectToChangeView viewData)
>
> They work together like so:
> (setq viewData (getViewData vpObjectWithDesiredView))
> (putView vpObjectToChange viewData)
> or simply
> (putView vpObjectToChange (getViewData vpObjectWithDesiredView))
>
> Now what I don't know is how easy it is to pass viewport objects stored in
> VBA variables to lisp functions. I'm not a VBA programmer, but I lurk in
> this group because I do access the ActiveX object model via lisp and a lot
> of what is discussed here in this NG applies to me also. I'm willing to
bet
> that someone knows how to make this work. Good luck
> --
> Bobby C. Jones
>
> "Keith" wrote in message
> news:73A289740F2720A433CB5DEC1F10D7D5@in.WebX.maYIadrTaRb...
> > Thanks, Bobby
> >
> > Those routines are not very long so I copied them here. Since that code
> is
> > Lisp, I don't understand it. Can this code be converted to VBA? It
looks
> > like you extract the DXF group code values and use them. Is that
correct?
> > Where do you determine the current viewport?
> >
> > ;;;Arguments - ActiveX Viewport object
> > ;;;Retval - A list of data suitable to pass to
> > ;;;the (setview) function
> > (defun getViewData (vlaObj / entlst)
> > (setq entlst (entget (vlax-vla-object->ename vlaObj)))
> > (mapcar '(lambda (x y) (cons x (cdr (assoc y entlst))))
> > '(40 10 11 12 42 43 44 50 110 111 112 79 146)
> > '(45 12 16 17 42 43 44 51 110 111 112 79 146)
> > ) ;_ end of mapcar
> > ) ;_ end of defun
> >
> > ;;;Arguments - ActiveX Viewport object;
> > ;;;'view' data list as returned by (getViewData) or
> > ;;;(tblsearch "view" viewName)
> > (defun putView (vlaObj viewData)
> > (setview viewData
> > (cdr (assoc 69 (entget (vlax-vla-object->ename vlaObj))))
> > ) ;_ end of setview
> > ) ;_ end of defun
>
>