Unfolding plugin idea
-
To use 'tool' methods like onLButtonDown() etc it must be inside a 'Class' that is launched as a 'tool' by Sketchup. Then it looks for all of the built-in special 'tool' methods like activate(), resume(), onMouseMove() etc if one is found it's used - see the LineTool example for several of these - and of course the API Tool doc http://code.google.com/apis/sketchup/docs/ourdoc/tool.html.
You've wrapped your methods inside a Module - it won't work as a 'tool' unless they are inside a 'Class' [which could also be inside the Module] and/or you need to also launch it as a 'tool' - you'd use something likeplug_menu.add_item("Autounfold"){Sketchup.active_model.select_tool(Autounfold.new())}
- [assuming the tool is a 'raw' class called 'Autounfold'???]...
The code inside the class's initialize() method runs first, then the code inside the activate() method next - any other methods are linked to those, or auto-activate depending on what you do with the mouse etc... If you use a @state variable and set it to have different values [0, 1, 2 etc] as various 'steps' are completed in the tool's methods then you can control things like 'onLButtonDown()' - by having for examplereturn if @state!=1
in the first line of that method, so that method only becomes into play when you have set @state=1... NB: @ variables persist across methods in that instance of that class - @@ ones [initially set in the class itself, outside of any method]are remembered across uses of that class that session. -
Also, You can output text to the status bar vs alot of message boxes: http://code.google.com/apis/sketchup/docs/ourdoc/sketchup.html#status_text=
Message boxes are especially good for alerting the user of errors and debugging your code.And there is a book that may help you out, concerning sketchup ruby. You can download the full pdf for free: http://www.autosketchup.com/
-
Thanks Everybody ! With Your help I got it working.
After this long weekend I will post what I have done.
Still there are some problems, but those I will try to solve later.Matt
-
nice would be the possibility to make UV mam from this
-
Nice work. Thanks.
-
Hello Everybody
Here is result of my work.
Plugin will make a autounfold submenu , with 2 options: unroll and rotate to XY plane AND unroll and leave in plane of last element.
Select elements to unroll first and then activate tool.
Pick first face, and then pick one adjacent to define in which direction it schould be unfolded.Script is based on idea of unfoldtool , and made with help of this comunity.
Therefore no rights reserved, and no responsibilities to be taken by author.
Feel free to test,use and modify.
C&C welcome!Matt
-
Thanks! I will study it carefully. As you know I have an idea...
-
(old) Unfolding plugin idea
(new) [Plugin] Unfolding automatically
Hi Matt,
why do you do no official plug-in from this?
Nice work. Thanks.
You must not hide!Sorry my bad englishโฆ
Kuddl -
Hello
First, it is not finished, there are some things that I would like to change but have no time at this moment.
Second, it is not well tested, I know that on some conditions it will not work properly, I am still investigating the reasons.
Third, When it comes to large curved surfaces, that consist of more than 400 faces, because if the loops that sit in code it can freeze.So no official plugin yet.Still lots of things to improve.
Matt
-
[Solved] BUT ideas are appreciated I am busy with reworking the code , but I found a small problem.
First situation:
Rectangle in XY plane, with a normal vector shown.
Then this rectangle was split with a line into two triangles, again with shown normals.
No problem.
Second situation, with rectangle not in XY plane:
As you can see, there are smaal differences in coordinates.
But when checking if faces are coplanar ( by comparing normals, of planes of faces) it gives a false result.
Is there a walkaround? is it possible to perform some kind of rounding of coordinates?Thanks for help.
Matt -
Hello, i'm very interested into your plugin but it's not working on my computer... is it possible to use your plugin with mac ? i have sketchup 8? please help me to use your plugin i would like to make a model ...
-
@gade said:
Hello, i'm very interested into your plugin but it's not working on my computer... is it possible to use your plugin with mac ? i have sketchup 8? please help me to use your plugin i would like to make a model ...
Hi I will need some more informations to answer, I havn't used it in a long time, at least this version, but I see no reason why it should not work on Mac.
You can also take a look here:
http://www.papermodelers.com/forum/software/18100-spp-sketchup-paper-planes-tools-sketchup.htmlGreets
Matt
Advertisement