Someone please make this simple Ruby

Among the functions of Push/Pull, only the function of Push can be used with a double click.
I can’t find this simple and simple Ruby anywhere I ask, so I’d like to request a production. If anyone can make Ruby, please make them and distribute them. Please help.

Below is the code. ↓↓
Custom_push_tool.txt (1.6 KB)

moved to the Ruby API section.

1 Like

I think @face.move may not be what you are looking for. @face.pushpull seems to work (SU '24):

1 Like

It looks like AI generated bad code. Ie, the Sketchup::Face class does not have a #draw method.

1 Like

I don’t know what you mean, because on my machine a double-click repeats whatever was done, and works for both a push and a pull.

1 Like

There is no separate function. The repetition uses face direction to determine the direction. A Push performed from the reverse side of a face is a Pull when viewed from the front side.

2 Likes

The double click can be made to work but with the highlight I don’t think it’s useful.

You could do one click to highlight the selection and then a second click to push-pull. But you already know what you’re selecting so the highlight doesn’t seem necessary.

Another option would be to highlight the selection and whatever the ray hits, giving a preview (sort of).

1 Like

not really a good way to use pushpull. Also you are asking something that could be achieved by using the tool better.

as @3DxJFD shows, it only useful when it’s highlighted, and then you push it.

better way is simultaneous push by using Fredo PushPull plugin

1 Like

Okay!! Thank you, I didn’t know that such a category existed.

Oh! The feature you showed in the video seems to be the ruby I’ve been searching for all my life. Could you please tell me the name of the ruby and where I can download it?

That’s right, exactly. I don’t know how to code at all, so I created it using Chat GPT.

1 Like

I saw your other post or I would not have understood what you were trying to do!

So there are a few things I was trying to show and I think others pointed out… 1) no good user interface reason to double click to get the face to move. If a tool is active most users just expect it to do what it does… with one click. 2) It isn’t clear whether you’re trying to highlight the face you want to pull outward or the face you want to connect to. On the one hand, if you know which face you’re clicking to move, why highlight it? 3) On the other hand, if you know you want to connect to whatever face is opposite, why highlight that? I kind of like that you could cancel the highlight preview of where the pull will hit if it doesn’t hit where you want it. But just clicking and undoing if it’s wrong seems to about as good and you showed that you aren’t rotating to look at where the face hits anyway.

I’ll try to make a simple version and let you know.

1 Like

Thank you for taking the effort to look at my other posts.
Everything you pointed out in your post is correct. Ideally, it would be best if users could intuitively understand the direction of the extended face, just like the push/pull tool provided by SketchUp. However, I think this might be difficult to achieve in the Ruby development process. Unable to find a solution, I hastily studied how to create Ruby scripts to some extent, and although it’s rudimentary, I managed to implement the functionality I wanted to some degree. Here is the Ruby script attached below.

Since I am not familiar with such tasks and I started from scratch without any knowledge of coding, I created it by copying and pasting AI scripts, so it is quite clumsy. Additionally, it lacks several convenient features. Nevertheless, I hope this helps to convey that I need such functionality to you.

JHJ_Push.rbz (886 Bytes)

I didn’t have a chance to look at your code closely. But I can see it’s not wrapped in your unique namespace and module name.

That would be something like:

module JHJ
  module MyPushTool
    # your code here
  end
end

Also, no need for the TXT or the RBZ files. If you want to post a file, use Ruby, .rb files. Or share the code in a post, like this: [How to] Post correctly formatted and colorized code on the forum? - Developers - SketchUp Community

You need to learn how SketchUp extensions are structured: [Template] Multi-File, Multi-Class with SharedConstants Mixin - Developers / Ruby API - SketchUp Community

The tool could work something like in the following video. It might be possible to eliminate the ‘push’ when there is nothing in front of the raytest. That might be more intuitive. But it’s kind of cool.

In case it is not intuitive, there’s an information icon:

Screenshot 2024-06-06 235935

…just wanted to try this:

Screenshot 2024-06-07 000632

1 Like

Thank you for taking an interest in an amateur post like mine. Would it help your understanding if I uploaded the Ruby file like this?
JHJ_Push.rb (1.7 KB)

The intuitive direction determination for the push/pull feature I mentioned is as shown in the following video.


As shown in the video, the direction I want to push/pull is visually represented according to the mouse movement. Is it possible to implement such a feature in Ruby?

Well, it’s interesting! I’m an amateur too.

Yes, uploading the file is better than zipping it. I take it that you’re trying to zip the file so it can be installed… but you’re getting ahead of yourself. Also, if you post the code correctly, people can see it without having to download anything, which might lead more people to actually look at it.

But if you wanted to upload a folder - zipped or not- You don’t have a registrar / registration file with it. Also, you didn’t use a namespace and module name. You need both.

The registration file could be something like this:

Registration File
require 'sketchup.rb'
require 'extensions.rb'

module JHJ
  module PushTool
    PLUGIN_PATH = File.dirname(__FILE__)
    unless file_loaded?(__FILE__)
      loader = File.join(PLUGIN_PATH, 'jhj_push', 'main.rb')
      extension = SketchupExtension.new('JHJ Push Tool', loader)
      extension.description = 'An example extension for pushing faces to a maximum distance.'
      extension.version = '1.0.0'
      extension.creator = 'JHJ'
      Sketchup.register_extension(extension, true)
      file_loaded(__FILE__)
    end
  end
end

I don’t understand what you mean in the vid. If a user needs to move the face in or out, that implies they don’t know which way they intend to move the face before they begin moving it. Also, selecting the face, then moving it, then [do something], then the face connects to the other face (that you can’t see because you don’t want to rotate) is more steps.

So, the extension being launched from a keyboard shortcut or toolbar button and immediately doing what’s intended seems better. It could have no prompt or dialog, but then you wouldn’t be able to affect the max distance. This would be good if you only want to connect faces but never extrude to a specified distance.

Here’s an example that lets the user immediately pull but also have an option to push. It doesn’t pull if the raytest hits and push if the raytest misses, like before. Instead, it pulls or pushes until it hits a face or reaches the max distance. This means the behavior is more consistent/expected. I might change this example so that it doesn’t start with pull enabled… but that’s another issue.

2 Likes

@FJAY I saw that you hit like today. Have you had a chance to try getting a version of your extension working?

I continued to play around. I found a use for highlighting faces again: multiple selection push-pull. Also, I put an option to ignore faces:

2 Likes

I’m sorry, I’ve been busy with work and couldn’t respond sooner.
I am truly impressed by your effort and dedication. However, on the contrary, your work is becoming increasingly complex. We need to remember the original purpose I had when I proposed this topic. My goal is to reduce the complexity and simplify the modeling process to minimize the time and effort required for modeling. But ironically, your tool is becoming more complex and demanding more effort.

The functionality I want is really simple. While in the push/pull state, you select a face, specify a direction with the mouse, and press a predefined key to extend infinitely in that direction. It should stop when it encounters a pre-created point, line, face, or group. It only sounds complicated because I’m explaining it in words.

2 Likes

What happens if it does not hit a face, can SketchUp do infinite?

The hard part of this is to detect when any part of the face, no matter how small, hits any part of something else, again no matter how small. In effect, that means testing every point of the face against every point of the potential obstruction. Anything less will have rare but possible bugs.