How can you combine two ruby scripts?
-
Is it an easy enough task to combine two scripts? For example I'm trying to combine an offset script with an inverse selection script so that I can hit a shortcut and it will run the offset script (offsetting each square of a surface with a grid pattern by 1"), and then automatically invert the selection so I have only the inside squares selected which I can then move. Sort of a very controlled type of greeble.
But the main question is, is there a set way to combine these scripts? I tried copying some text from one to the other without much success. Perhaps there's a command to run another ruby within the ruby?
-Brodie
-
There are probably more well educated persons who can answer this, but I'll give it a shot!
You could run the scripts with some conditionals. If something happends then do this. else do that, and so on. You will have to look up some Ruby learing rescources to look into that.
Otherwise. You can use different icons to "launch" each method.
In any way it would probably be good to put both script in it's own method so they don't conflict with each other.
And then you could call them IF something happends like the first advice.I'm just giving you the BIG picture here. You probably have to read up a little on ruby.
If this isen't what you was asking for, and the answer is to basic I apologize.Happy coding!
-
Some scripts are designed to be run alone, others will accept 'arguments' - so just as you you could do within a new tool, one method a could call another method, passing 'arguments' to it.
If you want to combine just some aspects of code from two scripts then try to understand what each of them do and then write your own code using parts of the originals as needed...
The 'offset.rb' script can be called from any other script if you pass an argument e.g. 'face.offset(12.3)'... There is already a 'multiple face offset' tool you could recast as you want...
The selection of the original faces could almost be 'automatic' ?? -
TIG, actually, ya, that was the script I was talking about (the multiple offset ruby). What I'm trying to get, ultimately, is a sort of beveled greeble but instead of working off percentages it would offset in 1" and then push the face "out" 1". Currently I still have to use the move tool for the last part and just use it on planes facing the same direction.
If I can get this to work as I'd want it would at least help automate the first two steps - offsetting and selecting the correct faces (although the multiple offset script is giving me some hassle as it stops anytime it encounters any small anomaly).
-Brodie
-
Select the faces, get the offset, extrusion and bevel in a dialog, offset [-ve] them multiple-ly...
The original faces should still be selected ?
Now do a pushpull on them by 'extrusion' multiple-ly...
Now the trick after the pushpull the original face is 'lost'.
You can find a matching face with equivalent vertices all offset! by the extrusion dim along the original face.normal...
Now apply a scaling transformation to the face.vertices to make the bevel ? OR offset the face again by the bevel i plan and then transform [translation] the remaining face vertices up to make the 'bevel' angled parts. -
Well, most of that is way over my head but if I understand what you're saying that's basically how the greeble plugin I tried awhile back works. Only problem is that when it scales you can only scale by a percentage, you can't say "bring each side in 1""
I didn't really understand your alternative idea at the end but I don't think I could code it at any rate. My hope was just that I might be able to hack together some existing plugins Frankenstein style. I know just enough coding to have a vague understanding what's going on in a simple script but not near enough to be able to create something new.
You said before that you could access a tool like Offset within a ruby, and I see where multiple offset is doing this. Is it possible to access ANY ruby within a ruby? Could I just let the multiple offset tool run and then tack on some code at the end that tells it to run the invert selection ruby?
-Brodie
-
Brodie, If I understand you correctly what you want to end up with is a beveled edge,ie inset 1" and raised 1". Is that correct? If so I think I have the solution.
-
That's right. Here's an example of the panels I'm doing
-
It seems to me if you make a component 'windows' OR a component 'panels' [there must only be a relatively few window/panel types - you'll give the special subcontractors nightmares otherwise!] and then you can manually place them and then perhaps use Component-of-Components and Move+Ctrl to copy NNx if there's a regular spacing - on one story - and them select and Move+Ctrl to copy them up to the next story you're done - I don't understand what it is you want to do otherwise
Once some simple modeling is done a plugin isn't going to be very helpful -
Well, these aren't really panels. It's stucco/eifs with joints so the subs don't care if there are 3 sizes or 30 because the joints are located on site. It's not like a cement panel where a form needs to be made and they need to be modular. Regardless, I have no influence on this. The fact is there is very little constancy.
What you're describing seems to be the best method without a ruby. Once some simple modeling is done, a ruby is unnecessary true, however it's quite a lot of simple and repetitive modeling, which is what ruby's tend to excel at. If you had the option would you do it your way? Or would you bring in the CAD drawings, run Make Faces on it and then run a Make Bevels script on it and be done?
-Brodie
Advertisement