@jolran said:
Glad to help!
For gluebehavior you can have a look in my code in "Hatchfaces".
(I don't know of any other scripts using that method..
)
BUT! be adviced, I'm novice programmer so there might be lack of style and
best practices in there.
I am very new to Ruby programming as well. I am having very hard time with structuring my code. Here is a small example related to one of my problems. I created a component with some constraints and place this component in the model. Before placing the component, I want to get the length of the component by clicking two points in SU and use that length for my component length.
To keep my code clean I am trying to separate my class into following folders or lets say module
Module 1:- this has the UI related classes like my toolbar and commands
Module 2:- this is supposed to have all the "Sketch up" api methods.
Module 3:- In this module I want to keep all my components related classes.
And this is how I always structured my plugin code in AutoCAD. With sketch up I want to do the same way but I am having hard with separation of code. In my API module I want to have a function lets say "get_length" which will call the tool class which does the mouse tracking etc and returns a length back when user is done picking two points or hits cancel. So far I have a class which is doing every thing i want to do related to getting the length. Only problem I am having is passing that length back to my api module when user is done. I am not sure how to get that length back, on the other hand I think I am over complicating this because of my lack of SU api knowledge.
Here is code snippet from my API class.
class Aqx_api
def self.getActiveModel
return Sketchup.active_model
end
def self.getLength
aqxGetLength = Aqx_Get_Length.new
getActiveModel.select_tool aqxGetLength
end
end
# Class for getting the length which is based LineTool class from plugin examples.
class Aqx_Get_Length
# This class has code from LineTool. So I am not pasting every thing here.
end