Jump to content

Hideprecision set to 1 before plot?


mojo8997

Recommended Posts

How can i set hideprecision to 1 before i plot? then set it back to 0 after it plots? im told i could use a reactor but im not that far into my lsp skills yet, any help would be much appreciated!

 

 

i just found this but i dont quite get it

 

(defun CommandReactor (objReactor lstCommand)
(cond
 ((= (car lstCommand) "PLOT")
  (print "\nDo stuff before plot: \n")
 )
)
)
(setq rxnCommand ( vlr-editor-reactor nil '((:vlr-commandwillstart .  CommandReactor))))

Link to comment
Share on other sites

well i have this but it not working

(defun edgplotstart (objReactor lstCommand)
(cond
((= (car lstCommand) "PLOT")
(print "\n Hideprecision Set to 1")
(setvar "hideprecision" 1)
)
)
)
(setq rxnCommand ( vlr-editor-reactor nil '((:vlr-commandwillstart . edgplotstart))))


(defun edgplotend (objReactor lstCommand)
(cond
((= (car lstCommand) "PLOT")
(print "\n Hideprecision Set to 0")
(setvar "hideprecision" 0)
)
)
)
(setq rxnCommand ( vlr-editor-reactor nil '((:vlr-commandended . edgplotend))))

well i dont think its working

 

 

Command: _plot
"\nHideprecision Set to 1"
"\nHideprecision Set to 1"
"\nHideprecision Set to 0"
"\nHideprecision Set to 1"
"\nHideprecision Set to 0"
"\nHideprecision Set to 1" Effective plotting area:  10.60 wide by 15.91 high
Effective plotting area:  5.69 wide by 1.05 high

Plotting viewport 2.
Effective plotting area:  5.70 wide by 1.71 high

Plotting viewport 3.

Plotting viewport 1.

"\nHideprecision Set to 0"

Link to comment
Share on other sites

Try this:

 

(defun c:HidePrecReactor nil
 (vl-load-com)
 ;; Lee Mac  ~  07.05.10

 (  (lambda ( data / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (vlr-added-p react)
          (vlr-remove react)
          (vlr-add react)
        )
        (setq react
          (vlr-command-reactor data
            (list
              (cons :vlr-CommandWillStart 'SetHide)
              (cons :vlr-CommandEnded     'RestoreHide)
              (cons :vlr-CommandCancelled 'RestoreHide)
            )
          )
        )
      )
      (princ
        (if (vlr-added-p react)
          "\n** Reactor Activated **"
          "\n** Reactor Deactivated **"
        )
      )
      react
    )
   "Prec-Reactor"
 )

 (princ)
)

(defun SetHide ( reactor params )

 (if (eq (strcase (car params)) "PLOT")
   (progn
     (setq oldHide (getvar 'HIDEPRECISION))      
     (setvar 'HIDEPRECISION 1)
     (princ (strcat "\n<< HIDEPRECISION set to 1 >>"))
   )
 )
 (princ)
)

(defun RestoreHide ( reactor params )

 (if (and oldHide (eq (strcase (car params)) "PLOT"))
   (progn
     (setvar 'HIDEPRECISION oldHide)
     (princ (strcat "\n<< HIDEPRECISION set to " (itoa oldHide) " >>"))
     (setq oldHide nil)
   )
 )
 (princ)
)


Turn on the reactor using HidePrecReactor (turn it on once), and turn it off with the same command.

Link to comment
Share on other sites

nice!! man your badass, i was telling my friend about you lol (hes the one teaching me lisp)

 

it is getting caught at here

 

(and oldHide (eq (strcase (car params) "PLOT")))

i changed it to

 

(and oldHide (eq (strcase (car params)) "PLOT"))

but something is still happening funny so i just made it

 

(defun RestoreHide ( reactor params )

 (if (and oldHide (eq (strcase (car params)) "PLOT"))
   (progn
     (setvar 'HIDEPRECISION 0)
     (princ (strcat "\n<< HIDEPRECISION set to 0 >>"))
   )
 )
 (princ)
)

 

thanks a lot!!

Link to comment
Share on other sites

Ahh nice one - I think I perhaps wrote it a bit too quick :oops:

 

Thanks for the compliments :)

 

Updated my original code to sort out that typo :)

Link to comment
Share on other sites

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