Well that bug has been a big pain in my rear end for years when modeling.
Posts
-
RE: Unrequested process.
-
RE: Module variables and nested class
I don't think class variables in modules has any use.
In general people (when you search the net for Ruby) will advice against class variables if you can avoid them due to that they are troublesome when you create subclasses.
-
RE: [Plugin] Plugin to profile/optimize code
That is mighty interesting. Thanks for sharing.
-
RE: Module variables and nested class
Just because observers doesn't have access to the instance variables of the parent module. All I need observers for are tell when when things change - so I prefer to keep the logic that modifies stuff in the parent module along with the rest of it. It's an organization thing.
-
RE: TT LibĀ² installerProblem?
Can you post a screenshot of your Plugins folder, with the Explorer toolbars?
Btw, are you updating TT_Lib, or installing fresh? You might have to manually remove TT_Lib2 before updating it.
-
RE: Unrequested process.
I don't know. I'll see if I can bump the issue again. Last time I heard anything about it I was told it was as high-risk fix. But then again, it's a really annoying bug.
-
RE: Detecting a flipped transform.
This is digging up an old thread, but here's a snippet I think should work:
<span class="syntaxdefault"><br />module TransformationHelper<br /><br /> def flipped_x</span><span class="syntaxkeyword">?<br /> </span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_z </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">axes_dot_products</span><span class="syntaxkeyword">()<br /> </span><span class="syntaxdefault">dot_x </span><span class="syntaxkeyword">< </span><span class="syntaxdefault">0 </span><span class="syntaxkeyword">&& </span><span class="syntaxdefault">flipped</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_z</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">end<br /><br /> def flipped_y</span><span class="syntaxkeyword">?<br /> </span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_z </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">axes_dot_products</span><span class="syntaxkeyword">()<br /> </span><span class="syntaxdefault">dot_y </span><span class="syntaxkeyword">< </span><span class="syntaxdefault">0 </span><span class="syntaxkeyword">&& </span><span class="syntaxdefault">flipped</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_z</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">end<br /><br /> def flipped_z</span><span class="syntaxkeyword">?<br /> </span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_z </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">axes_dot_products</span><span class="syntaxkeyword">()<br /> </span><span class="syntaxdefault">dot_z </span><span class="syntaxkeyword">< </span><span class="syntaxdefault">0 </span><span class="syntaxkeyword">&& </span><span class="syntaxdefault">flipped</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_z</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">end<br /><br /> </span><span class="syntaxkeyword">private<br /><br /> </span><span class="syntaxdefault">def axes_dot_products<br /> </span><span class="syntaxkeyword">[<br /> </span><span class="syntaxdefault">xaxis</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dot</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">X_AXIS</span><span class="syntaxkeyword">),<br /> </span><span class="syntaxdefault">yaxis</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dot</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Y_AXIS</span><span class="syntaxkeyword">),<br /> </span><span class="syntaxdefault">zaxis</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dot</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Z_AXIS</span><span class="syntaxkeyword">)<br /> ]<br /> </span><span class="syntaxdefault">end<br /><br /> def flipped</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">dot_z</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">dot_x </span><span class="syntaxkeyword">* </span><span class="syntaxdefault">dot_y </span><span class="syntaxkeyword">* </span><span class="syntaxdefault">dot_z </span><span class="syntaxkeyword">< </span><span class="syntaxdefault">0<br /> end<br /><br />end<br /><br /><br />module Example<br /><br /> def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">inspect_flipped<br /> tr </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">transformation<br /> tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">extend</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">TransformationHelper</span><span class="syntaxkeyword">)<br /><br /> </span><span class="syntaxdefault">p tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">flipped_x</span><span class="syntaxkeyword">?<br /> </span><span class="syntaxdefault">p tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">flipped_y</span><span class="syntaxkeyword">?<br /> </span><span class="syntaxdefault">p tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">flipped_z</span><span class="syntaxkeyword">?<br /> </span><span class="syntaxdefault">end<br /><br />end<br /></span>
-
RE: SketchUp 2014 Wishlist
@anton_s said:
It would be nice to have entity.path function that will return an array of parent entities.
This isn't doable because an entity, say a face, might appear multiple times in a model due to components. When you have a reference to an entity you must keep track of the path from where you picked it yourself.
There is model.active_path that will give you the path of the active context if you obtained the reference for the entity there. And the PickHelper will also return a path for each possible pick solutions.
-
RE: Unrequested process.
There is an annoying bug under Windows where a Soft/Smooth operation is done after the SketchUp window has become unresponsive for a moment and then returns. Any selected geometry will then have a Soft/Smooth operation. You can undo this operation if you catch it right after it happens.
-
RE: Module variables and nested class
Alternatively, in the case of observers, I usually define methods in the root module which I call from the observers - defining minimum amount of code in the observer class itself.
-
RE: Module variables and nested class
Use attr, attr_reader, attr_writer, attr_accessor to create methods to access the module/class's instance variables.
The class << self syntax is needed for modules (class attributes). If you define instance attributes that is not needed.
<span class="syntaxdefault"><br /></span><span class="syntaxkeyword">require </span><span class="syntaxstring">'sketchup.rb'<br /><br /></span><span class="syntaxdefault">module JBB_MyModule<br /><br /> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">model </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">layers </span><span class="syntaxkeyword">= @</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">layers<br /> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">customVar </span><span class="syntaxkeyword">= </span><span class="syntaxcomment">#something<br /><br /> </span><span class="syntaxkeyword">class << </span><span class="syntaxdefault">self<br /> attr_accessor </span><span class="syntaxkeyword">;</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">, ;</span><span class="syntaxdefault">layer</span><span class="syntaxkeyword">, ;</span><span class="syntaxdefault">customVar<br /> end<br /><br /> </span><span class="syntaxcomment"># Some code using these @variables<br /><br /> </span><span class="syntaxkeyword">class </span><span class="syntaxdefault">JBB_LP_AppObserver </span><span class="syntaxkeyword">< </span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">AppObserver<br /><br /> def onNewModel</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">newModel</span><span class="syntaxkeyword">) </span><span class="syntaxcomment">#or onOpenModel<br /> </span><span class="syntaxdefault">JBB_MyModule</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">model </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">newModel<br /> JBB_MyModule</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">layers </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">newModel</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">layers<br /> JBB_MyModule</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">customVar </span><span class="syntaxkeyword">= </span><span class="syntaxcomment">#some other thing<br /> </span><span class="syntaxdefault">end</span><span class="syntaxcomment">#def<br /><br /> </span><span class="syntaxdefault">end</span><span class="syntaxcomment">#class<br /><br /></span><span class="syntaxdefault">end</span><span class="syntaxcomment">#module<br /> </span><span class="syntaxdefault"></span>
-
RE: Newbie
Here's some getting started tips to SketchUp Extension development: http://www.thomthom.net/thoughts/2012/01/golden-rules-of-sketchup-plugin-development/
Check out the rest of the blog for more articles.
-
RE: Area to text
Note that when computing the area of the faces you want to apply the transformation of the parent context in order to get the correct size. The Face.area method accepts and optional transformation argument.
-
RE: Strange behavior in derived class
.extend should work... It has worked for Geom::Point3d classes for me. Not tried Transformation, but it'd be surprised if it's different.
-
RE: Strange behavior in derived class
That's because SketchUp used an old method of allocating and initializing the data for the classes defined in C. The allocation is done explicitly in .new - which was something one had to do in Ruby 1.6. I noticed this myself when I tried to initialize an instance in Ruby C Extension using rb_class_new_instance - which failed. I had to explicitly call the .new method of the SketchUp classes.
-
RE: TT LibĀ² installerProblem?
Yea, there might be problems in updating, as there are Ruby C Extensions binaries. So if you have TT_Lib already installed you might have to close all SketchUp instances and manually remove the TT_Lib2 files.
I'll look into finding a way to solve that.
-
RE: TT LibĀ² installerProblem?
hm... Maybe this is a VirtualStore problem. Could you show a screenshot of the Plugins folder in Explorer, including the toolbar in Explorer?
-
RE: Change plugin variables within Undo
Do you have a reproducible snippet of code?
By flag, I assume you mean attribute or variable?