Yes, ruby does have a modulo operator - I said Dynamic Components doesn't provide a modulus function.
Latest posts made by danielbowring
-
RE: Hide/Show only every Nth Copied Instance?
-
RE: Hide/Show only every Nth Copied Instance?
You should be using a modulo operation for this. A modulo operation will give the "remainder" of integer division. SketchUp doesn't provide a mod function for DCs, so you'll have to create it as such:
a - (n * FLOOR(a/n))
where a is the index and you want to hide every N.
For example, if you have
HIDDEN=COPY - (3 * FLOOR(COPY/3))==0
, you'll get:
HIDDEN, VISIBLE, VISIBLE, HIDDEN
.
You can change the compared value (in the above example, 0) to be the "offset", but it must be less than n.
For example, if you have
HIDDEN=COPY - (3 * FLOOR(COPY/3))==2
, you'll get:
VISIBLE, VISIBLE, HIDDEN, VISIBLE, ...
.
-
RE: Guidelines for adding a method to existing classes?
@tt_su said:
Note that extending
Entity
instances would not be allowed by EW because the instances are global to everyone using the SketchUp environment. But for other types such as Point3d, Vector3d, String etc that would work.Here
delegators
can be useful.require 'delegate' module DanielB class SampleFace < DelegateClass(Sketchup;;Face) def inner_loops return loops.find_all { |l| l != outer_loop } end end def self.demo face = Sketchup.active_model.selection.find { |e| e.is_a?(Sketchup;;Face) } return if face.nil? face = SampleFace.new(face) puts face.inner_loops end end
-
RE: Need Help: DC constrain min/max scaling size
If you want to avoid if statements, you can use
SMALLEST
andLARGEST
like so=SMALLEST(MAX_VALUE, LARGEST(MIN_VALUE, value))
-
RE: Migrating plugins to SketchUp 2013
Epic bump, but is there any news on this? Was upgrading the installation ruby put on the backburner? Should we still be expecting this sometime in the future (or a complete library at least)?
To me at least, this seems like a really important feature - plugins and the community around them are a powerful part of sketchup.
-
RE: [Project] Community Documentation Effort
@tt_su said:
Just so you're aware, we're looking into new solution for the API docs. I don't know of any time frame, yet though.
That's great! I'll continue working on this in the meantime, though. There's still a lot of community info to round-up and it may even come of use once you guys have whatever it is you're planning sorted.
Here's hoping you deprecate this soon
-
RE: [Project] Community Documentation Effort
@rich o brien said:
Is there a means of embedding that on a webpage here?
I doubt there will be any particular mechanism (as there is for gists) because of demand reasons.
-
RE: [Project] Community Documentation Effort
Only other one I'm aware of is JimFoltz's, but his doesn't allow the kind of stuff a wiki can.
-
[Project] Community Documentation Effort
Hey,
It's no secret that the documentation for the ruby API has its problems. We've asked for problems to be fixed (and we had comments for a while!) but it seems the dev team is too busy with other things to maintain it (which, in-of-itself is a good thing - SketchUp improvements!)
So, I've started working on a community written API documentation. I've mostly decided on a style and layout, but before things are set in stone I'd like to have some input from other people.
The project is hosted on Github and is made of of two parts:
- A Wiki to hold information on all the classes, modules, methods, ... as well as tutorials and guides
- A repository for non-trivial examples and resources (such as images)
I'll be waiting a few days before I start the real effort so I can (hopefully) get some feedback from everyone. I suggest looking at the wiki page for
UI
,UI::WebDialog
andUI::WebDialog#write_image
for an example of each main "type" of page (module, class, method).I know a lot of the information is scattered around already (especially here on these forums), but hopefully we can consolidate it into one, organised location.