Author Topic: viewport reactor  (Read 2850 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
viewport reactor
« on: August 04, 2006, 10:07:45 AM »
i was messing around with an example reactor i saw in augiworld. i am trying to write a reactor that will set the border layer current when the mview command is executed. i saw somewhere recently someone doing this through events in vba which i think would be better but i have no clue how to write that. i put this in my acad.lsp and when i start a drawing i get this:

MVIEW ; error: no function definition: HYP-CMDABORT

Specify corner of viewport or
[ON/OFF/Fit/Shadeplot/Lock/Object/Polygonal/Restore/2/3/4] <Fit>:
Specify opposite corner: Regenerating model.
; error: no function definition: HYP-CMDABORT

can somebody help me out or send me something in vba to look at perhaps? thanks

dan

Code: [Select]
;; Load the visual lisp library

(vl-load-com)

;; Check to see if our custom command reactors
;; have been loaded into the current drawing

(if (= hyp-rctCmds nil)
  ;;Add the command reactors and the custom callbacks
    (setq hyp-rctCmds (vlr-command-reactor nil '((:vlr-commandCancelled . hyp-cmdabort)
                                                 (:vlr-commandEnded . hyp-cmdabort)
                                                 (:vlr-commandCancelled . hyp-cmdabort)
                                                 (:vlr-commandWillstart . hyp-cmdabort)
                                                )
                      )
    )
)

;; Callback used when the user presses escape
;; or when the command ends by itself or due to
;; a problem

(defun hyp-cmdabort (param1 param2)
   ;; Check to see if our global variable has a value
   ;; If it does then set the layer to current

   (if (/= hyp-gClayer nil)
     (setvar "clayer" hyp-gClayer)
    )

   ;; Clear the global variable

   (setq hyp-cmdStart (param1 param2)

      ;; Store the current layer in a global variable

      (setq hyp-gClayer (getvar "clayer"))

;; Check to see what command has been started, the
;; command name is stored in the param2 variable

(cond

   ;; If the MVIEW command is active then set the layer
 
      to the BORDER layer
   ((= (car param2) "MVIEW")(setvar "clayer" BORDER"))

   ;; If the Hatch command is active then set the current layer to HT

   ((or (= (car param2) "Hatch")
   (= (car param2) "BHATCH")
    )
      (setvar "clayer" HT")
    )
  )
)


EDIT: Fixed the typo in the title
« Last Edit: August 04, 2006, 10:10:17 AM by nivuahc »

LE

  • Guest
Re: viewport reactor
« Reply #1 on: August 04, 2006, 10:46:31 AM »
Add the command MVIEW into this one:

http://www.theswamp.org/index.php?topic=9441.msg137293#msg137293


It might suit your needs.

ELOQUINTET

  • Guest
Re: viewport reactor
« Reply #2 on: August 04, 2006, 11:59:15 AM »
LE i tried messing around with this but not sure what to do to get it to work

Code: [Select]
  (getvar "cmdnames")
  "UNDO,U,REDO,OOPS,STYLE,MVIEW,COPYCLIP,COPYBASE,CUTCLIP,NEW,QNEW,OPEN,*LAYOUT*,MOVE,COPY,*STRETCH*")))
     (cond
       ((and
  (wcmatch (getvar "cmdnames") "MVIEW")



Code: [Select]

LE

  • Guest
Re: viewport reactor
« Reply #3 on: August 04, 2006, 12:15:22 PM »
Dan;

Remove the MVIEW from here:

"UNDO,U,REDO,OOPS,STYLE,MVIEW,COPYCLIP,COPYBASE,CUTCLIP,NEW,QNEW,OPEN,*LAYOUT*,MOVE,COPY,*STRETCH*")))

And replace on both calls where reads:

(wcmatch (getvar "cmdnames") "PLACEVIEW")

With "MVIEW"

Now, run a test and see if works now.

ELOQUINTET

  • Guest
Re: viewport reactor
« Reply #4 on: August 04, 2006, 01:32:20 PM »
ok LE

I when i create a viewport it gives me the alert:

Now we can set here, the viewport to the desired layer

but how do i specify that I want to put it on the BORDER layer?

LE

  • Guest
Re: viewport reactor
« Reply #5 on: August 04, 2006, 04:40:23 PM »
Replace the alert line with:

Code: [Select]
;; the BORDER layer must exist
(vla-put-layer (vlax-ename->vla-object posible_viewport_ename) "BORDER")

ELOQUINTET

  • Guest
Re: viewport reactor
« Reply #6 on: August 07, 2006, 09:20:40 AM »
thanks so much LE it works great now. this will help us alot.

LE

  • Guest
Re: viewport reactor
« Reply #7 on: August 07, 2006, 02:46:52 PM »
no problem...