[Talk] Edit Mode Warning Flag (Beta)
-
Obsolete duiscussion.
**Get released version here: Edit Mode Warning Flag
` %(#008000)[# An example that displays an edit warning flag when
in edit mode of a component instance or group.
A SketchUp Ruby Example by Dan Rathbun, 23 FEB 2013.]`**
%(#BF4000)[Please consider this a test of concept, that was abandoned due to the "con" below.
The plugin was rewritten and released as CoastalConcepts::EditFlag]CONS:
- Modifies every model opened (if it does not yet have a Warning Flag Text object tagged with the plugin's attribute dictionary.
The toggle and options link are at the bottom of the View menu.
The options are saved between sessions.v1.1.0 :
- You can now see the position changes for the warning flags, without exiting SketchUp.
(But you must cycle through model editing context to see the position change take effect.)
- Changed the timer block per Fredo's suggestion
- Flag text is now a replacable template in the
@@say
hash - Flag also appears in the statusbar, until the mouse moves
editflag.rb
code sample removed, released version here: Edit Mode Warning Flag
-
Dan,
Just curious. Is there a reason why you don't create a local variable, say
model
, to hold the value ofSketchup.active_model
, as you use it several times. Is it for performance reasons?tid = UI.start_timer(1.0,true) { if Sketchup.active_model.valid? && Sketchup.active_model.tools.active_tool_id != 0 UI.stop_timer(tid) Sketchup.active_model.add_observer(ModSpy.new(Sketchup.active_model)) end }
Fred
-
Hi dan,
basically work on mac, but it generate a 'Save Changes' dialog on empty models, which is very annoying.
I'm not likely to use this myself but just pointing out this behaviour, and curious as to why it does this...
john
-
@unknownuser said:
Sketchup.active_model
, as you use it several times. Is it for performance reasons?Normally it would be faster to make one reference and reuse that - as you get an overhead of Ruby looking up the method calls every time.
-
@thomthom said:
@unknownuser said:
Sketchup.active_model
, as you use it several times. Is it for performance reasons?Normally it would be faster to make one reference and reuse that - as you get an overhead of Ruby looking up the method calls every time.
The key word is normally ...
... but the above is not a normal situation. This block executes only during startup, which differs between the PC and Mac, .. as to when the object returned by
Sketchup.active_model
is a validSketchup::Model
object. (On the PC, the template model gets loaded before the UI is initialized, ... on the Mac I think it happens after the menus and toolbars are built.)I was being extra cautious.
But Ruby has a trick that allows assignment within one of the conditional expressions (although it is considered very bad form,) ... so we possibly could do the following, because the conditionals will short circuit if any of them evaluate as
false
:tid = UI.start_timer(1.0,true) { if (model = Sketchup.active_model).is_a?(Sketchup;;Model) && model.valid? && model.tools.active_tool_id != 0 UI.stop_timer(tid) model.add_observer(ModSpy.new(model)) end }
-
@driven said:
basically work on mac, but it generate a 'Save Changes' dialog on empty models, which is very annoying.
I'm not likely to use this myself but just pointing out this behaviour, and curious as to why it does this...
This is the number 1 con for using a model note (Sketchup::Text
object,)... It modifies every model opened (if it does not yet have a Warning Flag Text object tagged with the plugin's attribute dictionary.)What we really need in the
UI
module is a "marquee" feature for displaying info, that does NOT modify the model.On PC we can do this using Win32API calls. (A window with a text label in it, optionally no border and no background. Or a WebDialog, which the caption bar is off. Jim played around with this in the past.)
I thot you had been working on this kind of feature for the Mac ?
-
Updated a bit. see notes in 1st post.
-
Should the menu item that toggles the flag warning OFF/ON be under menu:
- Edit1. Plugins
... feedback please !
-
I vote for 'Edit'...
-
Edit
Advertisement