Author Topic: regen reactor help  (Read 2501 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
regen reactor help
« on: March 14, 2015, 12:59:02 PM »
I have a question for masters of ACAD... So what I need is help with this or just an answer that this isn't possible... I've cobbled for a while on how to obtain width/height of current initial VIEW of ModelSpace Viewport... For instance if you press ctrl+1, tool palette of Property will pop up... Without selecting of any entity, only with just panning of rolling middle mouse wheel you can observe changes with width/height of viewport... Also if you type VIEW command you can see that main VIEW is "Current" and also in dialog box you can see almost the same width/height properties... So if this changing of those parameters is possible to monitor, how can it be done? Then after some time, I've actually tried to build reactor based on VIEWSIZE sys variable changing, but then comes my disappointment about this problem... I've figured that only user changeable sys vars can be monitored by sysvar reactor... All this was because of simple triggering REGEN command, so when working in ACAD and your mouse wheel zooming reaches very small or very big values - I mean when almost before message is displayed that maximum zoom is reached, I wanted to pass REGEN command to CAD automatically, so that user can rotate mouse wheel almost constantly without breaks in working... Of course this reactor will be fine if simple geometry was drawn during session, otherwise continuously regenerating drawing may slow or even crash session and working may become unpleasant... So I tried to create this reactor, so that when you activate it, you can also deactivate it after your task was completed with the same command... So is this after all possible? Not to mention that I can't even get entity that's containing width/height values of main VIEW/VIEWPORT...

Please, if you can provide some valuable info or maybe solution it would be great...

My code :

Code: [Select]
(defun c:regenreac nil (vl-load-com)
  (setq vs (getvar 'viewsize))
  (setq reactor (VLR-SysVar-Reactor nil '((:VLR-sysVarChanged . callbackfunction))))
  (if (null x)
    (progn
      (prompt "\nSysvar reactor enabled...")
      (setq x t)
    )
    (progn
      (prompt "\nAll reactors disabled...")
      (vlr-remove-all)
      (setq vs nil x nil reactor nil)
    )
  )
  (princ)
)

(defun callbackfunction ( react_obj lst )
  (if (eq (car lst) "VIEWSIZE")
    (if (or (> (getvar 'viewsize) (* 4.0 vs)) (< (getvar 'viewsize) (/ vs 4.0)))
      (progn
        (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport)
        (setq vs (getvar 'viewsize))
      )
    )
  )
)

Thanks, M.R.
« Last Edit: March 14, 2015, 01:12:56 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: regen reactor help
« Reply #1 on: March 14, 2015, 03:51:30 PM »
All I did find close to this topic was with Google-ing...

http://www.theswamp.org/index.php?topic=44428.msg496961#msg496961

Still no success in monitoring VIEWSIZE sysvar...

[EDIT : Added new code like Roy's version, but doesn't work in AutoCAD; Maybe in BricsCAD it'll work, who knows...]

Code: [Select]
(defun c:regenreac nil (vl-load-com)
  (setq vs (getvar 'viewsize))
  (setq reactor (VLR-AcDb-Reactor nil '((:VLR-objectModified . callbackfunction))))
  (if (null x)
    (progn
      (prompt "\nSysvar reactor enabled...")
      (setq x t)
    )
    (progn
      (prompt "\nAll reactors disabled...")
      (vlr-remove-all)
      (setq vs nil x nil reactor nil)
    )
  )
  (princ)
)

(defun callbackfunction ( react_obj lst / obj )
  (setq obj (vlax-ename->vla-object (cadr lst)))
  (if (member (strcase (vla-get-objectname obj)) '("ACDBVIEWPORT" "ACDBVIEWPORTTABLERECORD"))
    (if (or (> (getvar 'viewsize) (* 4.0 vs)) (< (getvar 'viewsize) (/ vs 4.0)))
      (progn
        (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport)
        (setq vs (getvar 'viewsize))
      )
    )
  )
)
« Last Edit: March 14, 2015, 04:06:49 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: regen reactor help
« Reply #2 on: March 15, 2015, 01:48:01 PM »
Marko, the code in your first post does not work in BricsCAD, the code in your second post however does. Maybe the code in your second post will also work in AutoCAD if you use the height property of obj instead of the viewsize variable.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: regen reactor help
« Reply #3 on: May 12, 2015, 12:19:12 AM »
Here is my newest discovery :

http://www.theswamp.org/index.php?topic=49415.msg545675#msg545675

No need for REGEN reactor...

HTH, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

CincyJeff

  • Newt
  • Posts: 89
Re: regen reactor help
« Reply #4 on: May 12, 2015, 11:50:49 AM »
I have a 2016 preview guide that states that a manual regen will no longer be required when zooming in. I haven't installed 2016 yet so I cannot verify. Anyone else able to confirm?