I use webconsole.rb Copyright (C) 2006 Jim Foltz
and have not looked for updates.
Keith
I use webconsole.rb Copyright (C) 2006 Jim Foltz
and have not looked for updates.
Keith
I thought you might find this interesting:
Last night I copied and pasted Dan's code into the web console and the code worked as expected. I added the dash at the end and also added a line to sort the file names still working. Wife says baseball is starting so I save the snippet and go in to watch the Reds. Now this morning I reload the saved file and nothing works. So I repeat the process from last evening and after pasting Dan's code in it again works. I have experimented today and found in the web console I cannot save and reload the code and get it to work. Any Thoughts on this??
Keith
Thanks for your help. Dan was correct the pattern I am looking for starts A00- thru A99- and his code worked very well.
Keith
I used this line of code to make an array of layer names. However it makes an array of layers not layer names.
layers = model.layers
lname = layers.each {|e| e.name}
It seems that I need to move the lname = inside the brackets but I had no sucess with what I tried. How should I make the array of names?
Question 2: When I have the layer names how would I select a name that has only characters 0 thru 9 in lname(1,2)?
Keith
Ok I tried the other method
c2=@model.entities.add_instance(ent_def,insert_tran)
when I first looked at the suggestion I thought that was how I added the instance in my origional code but closer inspection I noted that I was using
c2=@model.active_entities.add_instance(ent_def,insert_tran)
Once I replaced active_entities with just entities the code worked also.
Thanks
Keith
I used the Sketchup.active_model.close_active() and it worked as advertised.
Thanks (I wish sometimes I could find these on my own)
Keith
My script is intended to add a instance of a child component outside of the parent component. The script starts as a context selection when a child component is selected. The user needs to open the parent for editing to select the component.
UI.add_context_menu_handler do |popup|
sel = Sketchup.active_model.selection
unless sel.empty?
if sel.single_object?
obj = sel[0]
if obj.is_a?(Sketchup;;ComponentInstance) &&
obj.parent.is_a?(Sketchup;;ComponentDefinition)
popup.add_item(NC2SCENE) {
#
nested_component_command(obj)
#
}
end # component test
end # single_object?
end # unless empty?
end # add_context_menu_handler
and I have not found a method to close the parent component and then when I add an instance of the child it is added inside the parent which is not what I need. The instance needs to be added to the model outside of the parent component.
Thanks
Keith
Comp2Layer.rbYou might try this file:
keith
Thanks Dan that worked and was just what I needed.
Keith
For a context menu could I determine that the selection is a component within a parent component? I found the enity parent but can't figure out how determine that the parent is a component.
Thanks Keith
I have been following this topic as I have in the past used a file to store variables between sessions and my question is does the registry storing of variables only work on Win based computers and not on the Apple OS?
Keith
Thanks Dan I will post a file when I have the first one working. I am working on the grandson's Ar-moire so coding time is limited.
Keith
Thanks Dan for the info and help. Its a lot to digest but I will work on getting my plugins in the desired format. I am sure I'll have questions along the way. I am sure this discussion has also helped other beginning SU programers.
Keith
I call my shop K2 (pronounced k squared) Wood Shop so the grand-kids don't ask for too many curves in their furniture designs. So I will use the K2WS as my name space as that is the prefix I already used for the joint tools.
Question: If you use a authors name to wrap the plugin in as additional plugins are written if I understand the principle the new plugins will be added within the authors name space. If this is the case as an extension it seems that all the authors plugins will display as a single extension so the user only has the option of loading all the authors plugins or not any. For the few things I may write this is not a problem but for the more prolific authors I would think this would not be a good thing?
Keith
I will re read the listed docs and use that to format my program. From the outline you can see that the only user interaction after selecting the program is to provide a component name and there is the option to add the drawing scene or not. I have written it as a context right click on a component so tool icons and toolbar parts of the program are not needed. Thanks for the help.
Keith
I have a plugin that I wrote that operates on a component to place it a layer and makes a new page view for the dimensional drawing. This is an outline of the program.
The question I have should this program be written as a Class with def for each step, Module with def for each step, or single def as I currently have written it? I am convinced the long single def is not the proper format.
Keith
Sketchup.send_action('viewParallelProjection:') does not work on the PC. It returns true or false but does not change the view.
Sketchup.active_model.active_view.camera.perspective = false This command will change based on the true or false value
Keith
The BooTools works very well I think it was 10 bucks but well worth the money. It edits the selected component however it deletes the component used to do the editing so if you want both after the operation make a copy of the cutting component. I use it with the free version and have been very plesed
Keith
To start I have not used the toolbar to access my wood working joint tools so I don't know how toolbars are created. My K2WS_Joint tools contains an Tools-menu/menu/sub-menu/sub-menu to operate and in using the program I find it seems to be a drag to always need 4 mouse clicks to get the tool back again. Typically after using a tool you need a different tool for the next operation. For instance after making a M&T Joint at one end of a table apron you would need to change to the Tenon Only tool to make the tenon at the other end because the copied/flipped leg component would already have the mortise.
Now this is my question: Could I make a generic tool bar with 4 buttons that would respond to the current Type of Joint Tool??
When the M&T tool loads could it define the button operations as Joint Tool, Tenon Only, Mortise Only. Then if the user changed to the Dowel Joint tool the buttons redefined to Dowel Joint, Holes, Add Holes & Dowels, Dowels in Existing Holes?
Basically I am asking could the toolbar be context sensitive to the current Joint Tool selected? You can see by the code below how many options are available but the User will usually only need 1 or 2 of the Joint Tools in a given session.
if( not file_loaded?("K2_ToolsLoader.rb"))
# Access the main Tools menu
tools_menu = UI.menu "Tools"
# Add a separator and a submenu
tools_menu.add_separator
sub_menu = tools_menu.add_submenu("KK_Tools")
# Add two menu items to the submenu
sub_menu1 = sub_menu.add_submenu("Biscuits")
it1 = sub_menu1.add_item("Complete Biscuit Joint") {biscuitJointTool}
it2 = sub_menu1.add_item("Add Biscuit Slots & Biscuits 1 Comp") {biscuitSlotTool}
#it3 = sub_menu1.add_item("Add Biscuits") {biscuitTool}
it4 = sub_menu.add_item("BoxJoint_Fingers") {boxJointFingers}
sub_menu2 = sub_menu.add_submenu("Dominos")
it5 = sub_menu2.add_item("Complete Domino Joint") {dominoJoint}
it6 = sub_menu2.add_item("Add Holes & Dominos 1 Comp") {dominoHoles}
#it7 = sub_menu2.add_item("Add Dominos") {dominos}
sub_menu3 = sub_menu.add_submenu("Dovetails")
it8 = sub_menu3.add_item("Blind Dovetail Pins") {blind_dovetailPintool}
it9 = sub_menu3.add_item("Blind Dovetail Tails") {blind_dovetailTailtool}
it10 = sub_menu3.add_item("Thru Dovetail Pins") {dovetailPintool}
it11 = sub_menu3.add_item("Thru Dovetail Tails") {dovetailTailtool}
sub_menu4 = sub_menu.add_submenu("Dowels")
it12 = sub_menu4.add_item("Complete Dowel Joint") {dowelJoint}
it13 = sub_menu4.add_item("Add Holes & Dowels 1 Comp") {dowelHoles}
it14 = sub_menu4.add_item("Add Dowels") {dowels}
sub_menu5 = sub_menu.add_submenu("Mortise & Tenon")
it15 = sub_menu5.add_item("Loose-Tenon Joint") {looseTenonJointtool}
it16 = sub_menu5.add_item("Add Mortise 1 Comp") {mortiseC1tool}
#it17 = sub_menu5.add_item("Add Loose Tenons") {mortiseC1tool}
it18 = sub_menu5.add_item("Mortise & Tenon Joint") {mortise_TenonJoint}
it19 = sub_menu5.add_item("Add Tenon 1 Comp") {tenonC1}
it20 = sub_menu.add_item("Pocket Scw Holes") {pocketscw_holes}
it21 = sub_menu.add_item("Screw Holes") {screw_holes}
end
Currently the menu loads all the time but these tools are individual plug-in files and only load after the menu button is selected. One other option would be to make each tool a extension so the user would only load the extensions he/she would need for that session. This still could be toolbar overload if several tools were added for that session.
Any suggestions will be appreciated
Keith
This is the file that makes the menu items and loads the individual tool files as needed
Thanks for the code it worked just fine. I had finally found the piece I was missing and this is what I had come up with
model = Sketchup.active_model
entities = model.entities
ss= model.selection
entity = ss.first
selection_bb = entity.bounds
max_dir = "blue axis"
if selection_bb.height > selection_bb.depth
max_dir = "green axis"
if selection_bb.width > selection_bb.height then max_dir = "red axis" end
else
if selection_bb.width > selection_bb.depth then max_dir = "red axis" end
end
case max_dir
when "blue axis"
tr = Geom;;Transformation.rotation [0,0,0], [0,1,0], 90.degrees
entities.transform_entities tr, entity
when "green axis"
tr = Geom;;Transformation.rotation [0,0,0], [0,0,1], 90.degrees
entities.transform_entities tr, entity
end
Similar and the results are both ok.