Thank you TIG. I've done pretty much what you suggest in the renaming - the module is now JWMShapes, and the .rb file name is jwm_shapes.rb, whereas before both just said Shapes or shapes.rb. The menu label now says 3D Shapes (JWM) instead of just 3D Shapes.
Posts
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
Many thanks for the guidance and example, Jim.
I'll see what I can make of it, but not quickly I'm afraid.
As to the naming, I'm happy to change the name to avoid conflict betwwen the Trimble EW hosted and SketchUcation versions.
Thought the name change might take a while to get right, but it was a quick set of internal name changes, and I've tested that the new rbz file loads in Windows 7, SU2014 and SU2015 (the latter, in the 64 bit version).
Modification now done in downloadable v2.2.8 rbz file in original post at top of this thread.
Will update the Plugin Store by this weekend.
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
I'll see if I can work out how to convert the Group into a Component without losing the parametric properties of the Shape. I think I tried it a while ago, but if I remember correctly, the parametric properties don't survive the conversion from Group to Component, and I couldn't (at the time, anyway) see how to fix that.
It won't be soon, though - I haven't much time spare from other non-SU projects at the moment.
-
RE: [Plugin] Smooth Zoom 2.1.0 - 24 October 2021
Just tried this on 64-bit Win7 and SU 2015 Pro 64-bit - crashes on launch with error that starts:
Error Loading File C:/Users/John/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/ams_SmoothZoom/main.rb
Error: #<LoadError: 193: %1 is not a valid Win32 application. - C:/Users/John/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/ams_SmoothZoom/win32/2.0/ams_smooth_zoom.so>Presumably designed for 32-bit SU?
Had to delete from Plugins folder.
Works very nicely in older SU 2014 32-bit - it would be great to have it updated for 64-bit SU 2015, if possible.
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
I have looked at doing this, but found it too difficult for me. Sorry - I did try!
I did produce some code that would read the pick point (there are other plugins that I was able to adapt this from).
But I couldn't see how to incorporate that into saving the parameters of the object, or even how to draw it at the picked point. My Ruby coding skills aren't good enough, I'm afraid.
But I'd be very happy to have someone else edit the code to do this if they know how!
Even if they can't do that, it would be very good if the parametric.rb code could be modified to save and list the object parameters IN ORDER - at the moment, they are stored as a hash, which has no intrinsic order, and doesn't list in the order of entry, or necessarily even the same order on different uses. (Again, I'm not a good enough Ruby programmer to know how to do that).
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
The @Last version really ought to be removed from this Plugin store - the Google Sketchup team did an update of it several years ago, and mine/Trimble's was originally based on the previous SU Team version. However, with the advent of SU2014, the code was extended by me, then the code was updated to work with the new Ruby version, and Thomas Thomasson of the Trimble team helped me extensively to clean up the code. Trimble then chose to make it the first Community/Open Source SU plugin.
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
I'm afraid I don't quite know why this happens, or even definitely how to fix it, though I have a couple of suggestions to try.
It seems from the Ruby console dialogue that you included, that the plugin loader (Plugins/shapes.rb) isn't finding the file parametric.rb where it expects to, in the Plugins/jwm_shapes subfolder.
How did you install the Plugin? If through the Window/Preferences/Extensions/Install Extension button, it ought to put the files where they belong.
Please look and see what files/folders you have in your Plugins folder
"C:/Users/emre özel/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/"You should have one file from this plugin (jwm_shapes.rb) and one folder (jwm_shapes). The folder should contain the following files:
CHANGELOG.txt
extension_info.txt
mesh_additions.rb
parametric.rb
shapes.png
shapes.rb
shapes_icon.png
(and maybe shapes 221.rb)If those files aren't there, the installation hasn't worked properly.
If you manually unzipped the .rbz file, you may not have checked the option to preserve the folder structure.
To fix it, you might try (a) installing the plugin through the 'official' route - open SU, then go to Window/Preferences/Extensions [Install Extension] and select the downloaded jwm_shapes.rbz file to install.
or (b) change the extension of the downloaded file from .rbz to .zip, Extract the files in it (preserving the folder structure), to get the files and folder identified above, then copy the one file shapes.rb, and then the folder and contents jwm_shapes, into the Plugins folder.
I've just double checked that downloading the .rbz file from the top of this post, and using the official SU Extension installer works for me.
I don't think this a problem specifically to do with this one plugin. You could try downloading another plugin, and trying to install that.
If none of this works, try the Sketchup Extensions forum.
Best wishes
John McC
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
Minor update (to v2.2.7) - changed module name from CommunityExtensions to JWM in all four .rb files in .rbz archive to avoid potential conflict with SketchUp Extension Warehouse version.
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
Added Helical Ramp with Sides shape, with parameter for slope of sides from horizontal. Changed helical parameters to ask for start and end height, instead of pitch. Minor bug fixes.
-
RE: Can a Ruby tool return a value to a 'calling' program?
Thank you.
What you describe (calling the shapes or polyhedra routine from within the Tool class) is what I've tried.
And your hint and link has given me a lead to think about and experiment with. Won't have time to follow up tonight, but will look hard tomorrow.
Is it possible or allowable to have module-wide variables that aren't global? I don't think a class @@variable can be transferred between class instances of different classes or modules, if I understand correctly.
Or could I use a global variable that is named with an author prefix - like my initials jwm - to avoid namespace clashes? So, for example, $jwm_picked_point? Would that avoid clashes with other authors' plugins? Or are global variables just totally banned in SU plugins?
I was hoping to work the other way round from what you suggest, and indeed what I've already tried with partial success. I would like to invoke the PickPointTool from within the Polyhedra plugin, and return the picked point. Is that possible?
And if it is, and I invoke from polyhedra.rb an instance of the PickPointTool, how can I wait until that tool has been used to pick an origin point before continuing to the next line of code?
At the moment, I can only think of using a ToolsObserver to check the state of the PickPointTool, and having a timed loop checking until it responds with a 'point picked' state. Or, perhaps, defining getter and/or setter methods in the tool
-
Can a Ruby tool return a value to a 'calling' program?
I'm trying to extend the Parametric 3D Shapes plugin to allow the user to pick an origin point for the shape to be drawn, and also to develop another plugin to draw the five Platonic solids (the regular polyhedra: Tetrahedron, Cube, Octahedron, Dodecahedron and Icosahedron).
I've successfully adapted Matt666's 2008 plugin point.rb to allow me to pick a single point, or specify it in the VCB, and draw a cpointat the specified location.
But I can't quite see how to connect this with either of the two existing plugins I have - 3D shapes.rb and a new and as yet unpublished plugin polyhedra.rb. These draw a selected shape at the ORIGIN point.
I can (rather crudely) include the Polyhedron module code into the PickPointTool, and call for a new instance of the relevant solid Class (Icosahedron, etc), and use a Geom::Transformation.translation to move the polygon mesh which constructed Dodecahedron or Icosahedron, and use it with a global variable set at the pick point by the pickpoint tool.
But since I didn't construct the Tetrahedron, Cube, or Octahedron as a PolygonMesh object, I can't do exactly the same there.
I'd rather have the PickPoint tool be callable from another program, and return the value (somehow - perhaps just as a global variable?) to the calling shapes or Polyhedra plugin.
Is this doable? Do I have to use a global variable to return the pickpoint value?
And how would I tell the PickPointTool which Class (shape or polyhedron) is 'calling' so as to set an appropriate cursor? Can a Tool object be sent a parameter, and/or return a value or values? I've not seen any example tool which does, nor been able to see from the documentation how it might.
I'm still a relatively newbie Ruby programmer, and have so far mainly modified others plugins rather than developing them from scratch. In particular, I've found good starting points in the original SU Shapes plugin, the ClineTool, and in Matt666's Point plugins, and in the eBook From Edges to Rubies. So I have some pragmatic sense of what works, and have used the API documentation to help in my modifications.
My code is public at GitHub - see https://github.com/johnwmcc. It doesn't yet include latest mods to link the polyhedra and pick_point code, which is still in rough draft and developing. The versions on GitHub are self contained - the polyhedra plugin just draws the shapes at the origin, and the pick_point one just draws a cpoint at either the picked point, or at a point specified by entry into the VCB.
Any help would be gratefully welcomed.
Thanks in advance if you can advise me further.
-
RE: Why does this code break?
I'd been wrapping the code in Ruby tags, which I thought would give syntax highlighting, but it doesn't seem to here.
I didn't see the meaning of the icon for Code box, and hadn't happened to hover the mouse over it, so didn't see the tooltip either.
What's the purpose of the Ruby tags, then?
-
RE: Why does this code break?
Many thanks to all respondents.
I am a good deal clearer now about what's happening.
I found a workaround before I saw the responses, but they will stand me in good stead for future work.
I iterated on the base edges instead of separate edge1, edge2, and this worked:
` # Draw base and define apex point
base_down_by = -radius/3.0
triangle = container.add_ngon [0,0, base_down_by], Z_AXIS, radius * COS_ASIN_0333, 3Reverse to get front face outside
triangle.reverse!
base = container.add_face triangle
base_edges = base.edgesCreate the sides
apex = [0,0,radius]
for i in 0..2
edge = base_edges[i]
tetrahedron = container.add_face edge.start.position, edge.end.position, apex
container.each do |entity|
if entity.is_a? Sketchup::Face
entity.reverse!
end #if
end #do
end #for`Sorry, I can't seem to get the code to indent here, which makes it a bit harder to read.
-
Why does this code break?
I'm trying to develop a plugin to create regular polyhedra - initially, the Platonic Solids.
I have already extended the original Sketchup Shapes plugin, which draws a cone (among other shapes) and works.
But when I copy and adapt the code to draw a Tetrahedron, it fails, and I can't see why.
This works, for a cone:
` # Create the base
circle = container.add_circle ORIGIN, Z_AXIS, radius, num_segments
base = container.add_face circle
base_edges = base.edgesCreate the sides
apex = [0,0,height]
edge1 = nil
edge2 = nil
base_edges.each do |edge|
edge2 = container.add_line edge.start.position, apex
edge2.soft = true
edge2.smooth = true
if edge1
container.add_face edge, edge2, edge1
end
edge1 = edge2
endCreate the last side face
edge0 = base_edges[0]
container.add_face edge0.start.position, edge0.end.position, apex`I've adapted the code to draw a Tetrahedron, centred on the origin, with size specified by the radius from origin to corner points.
All the variables are defined.
This code doesn't work. (Errors shown below the code)
` # Draw base and define apex point
base_down_by = -radius/3.0
triangle = container.add_ngon [0,0, base_down_by], Z_AXIS, radius * COS_ASIN_0333, 3
base = container.add_face triangle
base_edges = base.edges
p "Base edges: " + base.edges.inspectCreate the sides
apex = [0,0,radius]
edge1 = nil
edge2 = nil
base_edges.each do |edge|
p "Edge: " + edge.inspect
edge2 = container.add_line edge.start.position, apex
edge2.soft = false
edge2.smooth = falseif edge1 container.add_face edge, edge2, edge1 end edge1 = edge2
end # do
Create the last side face
edge = base_edges[0]
container.add_face edge.start.position, edge.end.position, apex`For some reason I can't make out, the third base edge is being deleted before or during the .each do loop.
Error messages in Ruby console:
"Base edges: [#<Sketchup::Edge:0xef0cc88>, #<Sketchup::Edge:0xef0cc70>, #<Sketchup::Edge:0xef0cc58>]" "Edge: #<Sketchup::Edge:0xef0cc88>" "Edge: #<Sketchup::Edge:0xef0cc70>" "Edge: #<Deleted Entity:0xef0cc58>" Error: #<TypeError: reference to deleted Edge> D:/Documents/GitHub/my-polyhedra/src/jwm_polyhedra/polyhedra.rb:126:in
start'
D:/Documents/GitHub/my-polyhedra/src/jwm_polyhedra/polyhedra.rb:126:inblock in create_entities' D:/Documents/GitHub/my-polyhedra/src/jwm_polyhedra/polyhedra.rb:124:in
each'
D:/Documents/GitHub/my-polyhedra/src/jwm_polyhedra/polyhedra.rb:124:increate_entities' D:/Documents/GitHub/my-polyhedra/src/jwm_polyhedra/parametric.rb:49:in
initialize'
D:/Documents/GitHub/my-polyhedra/src/jwm_polyhedra/polyhedra.rb:255:innew' D:/Documents/GitHub/my-polyhedra/src/jwm_polyhedra/polyhedra.rb:255:in
block in module:Polyhedra'
-e:1:incall'
What's deleting the third edge before it can be used? When I comment out the line that draws the edges, the base triangle is drawn correctly.
The code excerpt starts at line 114. Line 126 (where the code errors) is the line
base_edges.each do |edge|
Any pointers as to what's happening here would be welcome.
I'm using SU2014 Pro, on Windows 7 Pro 64 bit.
Many thanks in advance to anyone who can help me understand why this code isn't working.
I can find a workaround, I'm sure, but I'm really puzzled and would like to understand what's going wrong.
John McC
PS. Further exerimentation merely confuses me.
If I omit the line in the do loop
container.add_face edge, edge2, edge1
then there aren't any errors, and the tetrahedron is partially drawn, with all three edges going to the apex, and the last side face drawn, but the other two faces not drawn.If I replace this code altogether by:
# Create the sides apex = [0,0,radius] edge1 = nil edge2 = nil for i in 0..2 edge = base_edges[i] tetrahedron = container.add_face edge.start.position, edge.end.position, apex end
I get a tetrahedron drawn as I want, but with the reverse of all faces outside.
It doesn't matter what order I specify the points of the faces, they always come out reversed.
How do I iterate over the faces of the tetrahedron to do
face.reverse!
PPS
This seems to do the trick:
container.each do |entity| if entity.is_a? Sketchup::Face entity.reverse! end end
-
RE: [Plugin] Angular Dimension
Is it/could it be possible to change the precision of the angular dimension displayed?
It defaults to 0.1 degree, which is fine for most practical purposes. But I'm trying to develop a plugin which will draw regular polyhedra, and while developing it, need high precision displays as I'm checking the maths of the geometry. I'm using a 'unit length' of one million inches, with five decimal digits of precision, for lengths, to check some of the mathematical formulae (Wikipedia seems to have at least one just plain wrong for the tetrahedron)!
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
I've added a further Shape - Helical Ramp.
The helical ramp further adds to the helix, and draws an (optionally tapering) helical ramp surface, with new ramp starting width and ending width parameters.
See first post in this forum for an updated v2.1 which includes the Helical Ramp.
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
Sounds good to have it added to the Plugin Store. What if anything further do I have to do before you can do that?
And what is the relationship between the Plugin Store and the new Trimble Sketchup Extension Warehouse? I've made a further Pull request for them to update the original with this and a wide range of other changes I made earlier, but it's been a few weeks since the release of the 2014 version of SU, and my updates to this plugin haven't yet made it to the new Warehouse.
Should it appear in both? One or the other only? I'd welcome your advice.
As to joining the Plugin Authors group, I'd be very pleased, but I'm only very sporadically active in writing (or usually, adapting others') plugins.
-
RE: [Plugin] 3D Parametric Shapes - makes placeable components
I've just updated the plugin to extend it to draw a Helix, and to work in SU2014.
The helix will be drawn upwards from the origin (by default, with positive Pitch), or downwards by setting the Pitch to a negative value.
The helix can be made left handed by setting No. of rotations to a negative value.
The helix can be drawn starting at any specified start angle from the x-axis
The revised plugin will be available on the new Extension Warehouse as soon as it has been accepted and updated there - awaiting only some SU team updates to mesh_additions.rb and parametric.rb, which I am not able to make.
Please see tne first post in this thread for download of the updated version 1.5.
John McC
-
RE: [Plugin] SketchUcation Tools
It works if I start Sketchup with Run as Administrator. And I hope it solves the problem that AutoInstall of another program from the Plugins Store didn't seem to work earlier, though it gave no error messages.
BUT...
I log on to the machine as an administrator already, and the Quick Launch bar icon for SU from which I usually launch it doesn't have the option to Run as Administrator.
So I have for the moment set the SU program properties to Run as Administrator by default, but I don't like doing that for programs supposedly written for Windows 7 or later.
There's no problem using Window/Preferences/Extensions/Install Extension when NOT running SU as Administrator, which needs rights to write to the Plugins folder, so why does the Tools 2.0 Plugin not get itself the same rights by default? Surely this Tools plugin shouldn't trip up over permissions like this? I don't expect that from programs written in the Windows 7 or later era.
Alternatively, would it not be better for SU to install its plugins in a folder that doesn't need special rights? In AppData for example, like other programs? I know you can have a script to load Plugins from other folders (and I have used that in the past), but would the Tools Plugin know about that?
John McC