[Code] Scarpino's SphereTool Sample ver 2.1.0
-
Hi Dan,
If people are working through Matt's Tutorials the path could remain
/Library/Application Support/Google SketchUp */SketchUp/plugins/asu_example_code/Ch11/sphere_tool.rb
...I did a lot of testing for Mat's book and I didn't have a problem with this one one the mac, where do you think it will fail?
The one we just couldn't get working on a mac, in the time frame for publication, was 'Skel Animation', please, please have a look at it
Just curious...
-
Updated examples to VERSION 2.1.0
Seems to work well on PC.
Mac testing welcome (as it wants to be a cross-platform coding example.)
-
@driven said:
If people are working through Matt's Tutorials the path could remain
/Library/Application Support/Google SketchUp */SketchUp/plugins/asu_example_code/Ch11/sphere_tool.rb
...My point is that as the example is.. it violates good practice. It is not wrapped in an Author namespace. We cannot all be defining classes in the global
ObjectSpace
. There will be clashes. The identifier "SphereTool" is just too common.Likewise.. it makes sense to have the textnames of your filespaces match your Ruby namespaces. It makes it much easier, when the time comes to type a
require
statement.@driven said:
I did a lot of testing for Mat's book and I didn't have a problem with this one one the mac, where do you think it will fail?
It will fail because the entities object is shared. In the example it used
$ents
, and I changed it to a class var@@ents
.If you have 2 models, open, and are using the the sphere tool on both models, and switch back and forth, between models... the tool should get confused. Both as to what context to add the geometry into, and what one to erase the center
$c_point
from.I've already changed
$ents
/@@ents
and$c_point
/@@c_point
to instance vars in the tool code.
I have also already modified the plugin methods, to track models, use the correct one, and keep an separate instance of the tool for each model.@driven said:
The one we just couldn't get working on a mac, in the time frame for publication, was 'Skel Animation', please, please have a look at it
Well, not having a Mac.. it will be difficult, unless I can spot some obvious booboo (or am aware of some kind bug on Mac.)
I did not really choose this one... it was posted publically by Keld, so I got "hooked"...
-
I'll try and find all my notes re. skell, interestingly, from what you just outlined, it may suffer from 'entities confusion', sometimes it ran and other times it just melted SU...
With Mat's help, I attempted to have this one work along the user drawn axis, so you could e.g. create a string of pearls.
Could you add or suggest how that could be done?
Then it's quite different from all the others.
john
-
Ok, all works on my mac,
I had to add the full path to the
require("/Library/Application Support/Google SketchUp 8/SketchUp/plugins/Scarpino/SphereMaker/spheretool.rb")
and I used a couple of icons I had from the last play, and I just used same full folder path for them as well.
I'll make some nicer ones if you want, this was my first attempt at making icons in SU... john -
@driven said:
With Mat's help, I attempted to have this one work along the user drawn axis, so you could e.g. create a string of pearls.
Could you add or suggest how that could be done?
See a new post (... I must have been reading your mind.)
I made a Library edition:
[ Code ] Scarpino's SphereUtil Sample -
@driven said:
I had to add the full path ... john
Oh to get SU to find the icons ??
I can prepend the icon paths with:
File.basename(__FILE__)
... the
UI::Command
class is cranky sometimes, with the icon locations.The icons look fine.. it's an example anyway.
I could tie it all up in an rbz for easy download. (Need to do the extension registration script first.)
-
@dan rathbun said:
VERSION 2.1.0
added some model tracking in to account for switching back and forth between models on Mac.I don't follow what's meant to happen, can't see anything new in my context menu.
When you switch between models, you switch tool and undo stacks automatically.am I being dim? john
@unknownuser said:
Oh to get SU to find the icons ??
no, before trying with icons, the path was failing.
I always use full or defined paths with require, it seems flakey. i.e.require path + "find"
OT: have you use find.rb with SU, it really shows up problems with 'Path' on mac's. -
@driven said:
I don't follow what's meant to happen, can't see anything new in my context menu.
Just a note, that when I referred to context menu, I was referring to entering and exiting group/component edit modes, via the context popup items "Edit Group" and "Close group".
You have to point to the group and right-click the mouse (or you don't see these items on the popup.)
Previously, the example tool, ignored any change in context, in fact, it was hard-coded to ALWAYS use the model's entities. So as Matt wrote it, you could not draw a sphere inside a group or component.
So in 2.0.0, I changed it to use
active_entities
, but once the construction point (for the center,) was drawn, the tool would put the sphere in the edit context of thec_point
, even if the user had changed the edit context.Version 2.1.0, checks to see if the edit context has changed when the second click is made, and acts within the new context, instead.
-
Well it on PC we can use a singleton instance of a tool, there's only one stack, and model.
But on Mac, this example now makes a new tool for each model's toolstack, but only ONCE.
His example was actually creating a new instance EACH time the toolbar button was clicked. That makes ruby garbage collection do more work.
And he was having ALL instances (models,) share 2 global variables.$ents
and$c_point
-
@dan,
I missed the fact you started the 2nd thread for this. I had 'another look at line tool, but what I meant is more like the Cyl.class at the bottom.i.e. After the user draws a line, a base circle 'path' is created, then at the line's 'mid-position' a 'filled circle' at 90º to path, with rad 1/2 line length is created, then the follow-me, clean-up, etc...
You end up with the new axis aligned to the original drawn line and could select the end point to continue a 'string of pearls'... If you the intersect those, the geometry could be line-up, without having to rotate groups manually. However, clytool dosen't work here...I've been distracted by almost having a WebDialog do the same things as my macMessage video shows. [but it's an 'almost' standard webdialog].
john
-
-
@driven said:
I'll make some nicer ones if you want, this was my first attempt at making icons in SU... john
A note about toolbar icons.
GIFs are not the best. (They are good for print ads, cartoons, etc.) But the edges look ragged.
You should save as PNG, as the edges are anti-aliased. (smoothed via blending.)
Advertisement