in case somebody using it, added a new project "IHL_CsR22ExtApp0" for Sketchup 2018/2017 x64 with ruby 22
Posts made by icehuli
-
RE: Extension using c#
-
RE: VCB and Shortcut Keys
additional observation:
If onKeyDown or onKeyUp returns true then onCancel is not triggered. It is blocked by onKeyDown/onKeyUp as well. -
Fresh active_view when click on menu item
Hi All,
any one knows how to refresh the active_view immediately when one click on a menu button while the mouse does not entering the view window.
What I try to do is to change the font size of view.draw_text by click on the menu buttons.
Currently I can only see the effects after I move the mouse entering the view area. It is not a big issue. But it would be great that I can update the view immediately once I click on the menu button.Thanks
I have tried:
Sketchup.active_model.active_view.refresh
It doesn't work.
-
RE: [Code] Skew Transformation from axes
@fredo6 said:
...and there is the magic formula by thomthom to check if two faces are coplanar (actually have parallel planes)
face1.normal % face2.normal > 0.9999999991
Fredo
I have never known this operator "%" on vectors. Fredo, could you explain to me how it works....
-
RE: Win32ole access violation
I think you need to use another thread for the WinForm windows, e.g MessageBox. I checked the following code. It works. It actually makes more sense to let the WinForm window in a separate thread other than the Sketchup's thread.
Imports System.Windows.Forms Public Class MyFunctions Private Sub showMessage(ByVal msg As String) MessageBox.Show(msg) End Sub Public Function AddMyValues() Dim Result As Double Result = 20 Dim t1 As New Threading.Thread(AddressOf showMessage) t1.Start(Result) Return Result End Function End Class
-
RE: Determine Whether a Point is 'in' a Volume
is there a better solution for this now?
-
RE: Ruby 2.0.0 Threads in SU | how to keep a subthread running?
@sr20vet said:
Yep, I've taken the native threads path. Got the thread running, got even an http server running in that thread. But now, GIL is killing me. Can't call ruby from that second native thread...
May I ask what exactly you are trying to do? I think you can call ruby from that second native thread.
One important point is that the ruby function needs to be involved in the ruby thread, i.e. the SU thread. So in the c-extension there should be two threads, one is the same SU thread, the other is your second native thread. All ruby codes need to run within the SU thread. -
RE: Load classification system via ruby code
Thanks Aerilius,
Thanks tt_su,I am waiting for the next release.
Anyway it is nice to see that SketchUp is on the way to BIM.
I have figured out how to add a classification to an entity, just in case that anyone would like to try the [highlight=#ffff00:3oppyo7z]undocumented[/highlight:3oppyo7z] API function "add_classification
".group.add_classification 'IFC 2x3', 'ifc;IfcBeam'
-
Load classification system via ruby code
Hi all,
Does any know if it is possible to load classification system into a model via Ruby Code? If yes, how? Thanks!
-
RE: Extension using c#
@dan rathbun said:
@icehuli said:
The C# stuff works on SketchUp 2014 with Ruby 2.0.0
ALL tutorials should show ALL objects being created INSIDE an Author's toplevel module.
We usually use the module name
Author
orAuthorNamespace
orCompanyNamespace
, etc., do denote that the end user should replace that name with their own toplevel module name.Only Ruby and the API (in rare cases,) should ever create classes at the toplevel (aka
TOPLEVEL_BINDING
.)Thanks for the reminding.
-
RE: Extension using c#
The C# stuff works on SketchUp 2014 with Ruby 2.0.0
-
RE: Getting Started with Sketchup's SDK
Hi Ellipser,
You can do so, but it is not easy.
Currently, as tt_su said, there is no real time inter-program API of SketchUp.
What you can do is:
Create a C or C++ extension, lets call it ApiBridge, and load ApiBridge in a ruby file that loaded by SketchUp.
In ApiBridge you need to- implement a C/C++ API wrapper to the Ruby API your self,
- maintain a communication to another program within a new thread.
Then you can do real time interaction with SketchUp through the ApiBridge.
For example, you can send/receive message/data to/from ApiBridge to do/get stuff to/from the SketchUp model.
-
RE: How to check showRubyPanel is ready to accept puts
maybe you can call winapi to try to search for the Ruby Console window and see if it returns something.
-
Extension using c#
Someone might be interested in using c# and .net stuff.
I created a very simple example to write a ruby extension in c#.
https://bitbucket.org/icehuli/sucsexttutorial -
RE: Memory management in C++ Extension
Should it be "<" instead of "<=" ?
for(int i = 0; i **%(#0000FF)[<]** EntityTree.depth(it2)-rootdepth; ++i)
The original code:
void Coll;;Reset(void) { TreeEntity;;post_order_iterator it2 = EntityTree.begin_post(); TreeEntity;;post_order_iterator end2 = EntityTree.end_post(); int rootdepth = EntityTree.depth(it2); while(it2 != end2) { for(int i = 0; i <= EntityTree.depth(it2)-rootdepth; ++i) if (it2.node->data) delete it2.node->data; ++it2; } }
-
RE: Memory management in C++ Extension
It is really hard to tell without more information of the code.
-
RE: Ruby panel on/off
On Windows PC:
you can do it with WinAPI. The script is from https://sites.google.com/site/jimfoltz/my-sketchup-plugins/ruby-toolbar.check the better version two floors down
require 'sketchup' require "Win32API" rb_console_title = $suStrings.GetString("Ruby Console") winapi_findwindow = Win32API.new("user32.dll", "FindWindow", ['P','P'], 'N') winapi_sendmessage = Win32API.new("user32.dll", "SendMessage", ['N','N','N','P'], 'N') rb_console_window = winapi_findwindow.call(0, rb_console_title ) #send the control a "WM_CLOSE" message (0x0010) winapi_sendmessage.call(rb_console_window,0x0010,0,"")
-
RE: Ruby panel on/off
@tt_su said:
What if there are multiple SketchUp windows open with the Ruby Console...?
It will not work perfectly.
so.. update:require 'sketchup' require "Win32API" rb_console_title = $suStrings.GetString("Ruby Console") winapi_FindWindow = Win32API.new("user32.dll", "FindWindow", ['P','P'], 'N') winapi_SendMessage = Win32API.new("user32.dll", "SendMessage", ['N','N','N','P'], 'N') winapi_GetWindowThreadProcessId = Win32API.new("user32.dll", "GetWindowThreadProcessId", ['N', 'P'], 'N') winapi_GetActiveWindow= Win32API.new("user32.dll", "GetActiveWindow", [], 'N') rb_console_window = winapi_FindWindow.call(0, rb_console_title) active_window = winapi_GetActiveWindow.call() active_pid = winapi_GetWindowThreadProcessId.call(active_window,0) rb_console_pid = winapi_GetWindowThreadProcessId.call(rb_console_window,0) winapi_SendMessage.call(rb_console_window,0x0010,0,"") if active_pid == rb_console_pid
-
RE: Speed up
Thanks tt_su,
I actually do a lot of calculations in the c++/c# extension. My code is kind of mixed up. I call stuff like rb_funcall, rb_num2int, rb_new_float, rb_ary_new, rb_ary_new3, rb_ary_push a lot. Yes, I will do a profiling to check my guess.
I guess that whenever something is drawn in SU, it first gets created(drawn), then SU immediately calculates the relation with other object (for example when a segment is drawn it may cut a face into two), then rendered, then the whole process again for the next entity. It is like including a "puts" routine inside Array.each, which slows down the whole thing.
-
Speed up
Hi all,
I am trying to speed up my plugin. I guess the bottleneck is the drawing operations in SU. So I am thinking about using the C SDK to create and store the drawings totally in a temporary .skp model file, then import it at once to the current SU active model. Do you think it may work or not?