SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

Sketchup::InputPoint#inference_type() #108

Open DanRathbun opened 6 years ago

DanRathbun commented 6 years ago

SketchUp Ruby API Feature Request

UPDATED issue title to read Sketchup::InputPoint#inference_type() per Julia's suggestion below. (Was originally proposed as Sketchup::InputPoint#tooltip_id().)

Also, added a list of nifty boolean constraint methods in the 4th post, below.

Sketchup::InputPoint#inference_type() method that would return an integer for faster comparison than strings returned by the Sketchup::InputPoint#tooltip() method.

In addition using integers would not suffer from the need to localize a bunch of String constants in each language, if it is the case that the API returns tooltip text in the user's localized language build. (The API docs do not say whther it is always English or the Sketchup::os_language.)

Along with this would be inference constants defined within a Sketchup::InputPoint::Inferences mixin module within the Sketchup::InputPoint class, such as:

INFERENCE TYPES

LOCATIONS

CONSTRAINTS

_...etc., etc.

Coders would use them by inclusion into their custom Ruby Tool classes thus:

module Company
  class NiftyTool
    include Sketchup::InputPoint::Inferences
    # class code
  end # class
end # module

REF FORUM TOPIC:

https://forums.sketchup.com/t/how-to-determine-from-point-and-constrained-on-line-in-ruby/73773/

thomthom commented 6 years ago

Logged as SU-40179

Eneroth3 commented 4 years ago

I was about to add this request again before finding it here. However, I think the method name shouldn't refer to the tooltip but something more general like inference_type. The tooltip text just happened to be the current hack to get this information. In a parallel universe SketchUp Ruby developers could just as well be writing ip.drawing_style == "Circle" as we are writing ip.toolltip.start_with?("On Face").

DanRathbun commented 4 years ago

I think the method name shouldn't refer to the tooltip but something more general ...

I'll go along with this. In fact I just realized that there are several unique "properties" to an inference.

Looking again at the list(s) in the first post, the first list is the basic inference "name" or "type".

Then each has a "location" modifier (implied local, "In Group", "In Component", "Outside Active", etc.)

And the last list is the "constraint".

I've updated the first post to label these 3 lists.


So the Sketchup::InputPoint class could also get some nifty fast Boolean methods as well. These most likely would be used for fast conditional branching:

DanRathbun commented 4 years ago

@thomthom Please update SU-40179 to reflect Julia's better method name suggestion, as well as the list of boolean constraint query methods above (and anything else up can think of.)