If you want your code to be compatible with SU8 and 2013 releases of SketchUp, you have to stick with Ruby 1.8, which is what's distributed with SU.
Posts made by slbaumgartner
-
RE: What version of Ruby should I start learning?
-
RE: Between different Macs plugin works and doesn't work
The reduced javascript code sends 'http error ' + xmlHttp.status back to Ruby and Ruby displays it in a UI.messagebox. The screenshots Walt posted on the other topic show that this callback arrived at Ruby correctly, so the problem is not with asynchronous javascript vs Ruby.
Most of the incidents of status 0 reported on the web attribute it to cross-domain requests. That is, for security reasons XMLHttpRequest does not allow requests to be sent to a domain other than the original one. I wonder if there is a bug (or maybe a "feature") in WebKit on Lion that made it less tolerant of this, for example, concluding that since the html and its scripts were loaded locally only the localhost should be allowed? I confess that even after reading a lot about this I don't quite understand it...
Garry, have you tried catching the onerror event? I wonder if it would tell you what is wrong when things fail on Walt's Mac..
Steve
-
RE: Between different Macs plugin works and doesn't work
@mwm5053 said:
I can't help you guys much sorry not a code man, but just some input if I may, the problem slbaumgartner is Lion 1.7.5 for me not MT Lion maybe it has a problem too. If Java is the culprit I have it enabled in Safari prefs but globally disabled in System Pref if that helps any.
Sorry, I didn't read back carefully to see exactly which versions of Mac OS were giving the problems.
But Javascript is completely unrelated to Java other than via an unfortunate choice of name. Your java settings have no effect on this.
Steve
-
RE: Between different Macs plugin works and doesn't work
Looking at the test app, it does seem to me that on Mac the async javascript could run ahead and complete the xmlHttp request before Ruby has returned from the initial callback. That is, the js function from_ruby kicks off the request and sets another js function to track progress, which on Mac can proceed without waiting for Ruby.
But that doesn't explain the status=0 error message or the different behavior between Mavericks and Mountain Lion...
-
RE: Import A Cut List
@jim said:
Well, you wouldn't need to import anything into the model. The imported components could populate the Components dialog for manual placement after the import.
True! That would handle cases with quantity greater than one too - just pull out however many you need (you can do that with my version too, since the components are there). I just followed the workflow Vigy requested.
Steve
-
RE: Inputbox too narrow
@garry k said:
I've got Russian working.
Will Chinese work the same way? Or will it not fit into UTF-8?
UTF-8 is a variant of Unicode, and definitely supports Chinese. However, as @driven pointed out, the display font you are using must also handle the extended character codes used by Chinese.
Steve
-
RE: Import A Cut List
@vigy said:
OOOH WOW! This is wonderful Steve, and it work great. Thanks a million!
As you mention, material not needed but layers would be nice if I'm allowed to have audacity to do so.Try this one! It should handle layers (I hope )
Another word of warning: For simplicity, I didn't process the header line to find out what is in which column, so if you rearrange things this plugin will fail in strange ways!
Steve
-
RE: Import A Cut List
@vigy said:
Hi Steve,
Attached a sample.
Thanks so much, Victor
Hi Victor,
Give the attached a try and let me know what happens. Put the rb file into your Plugins folder. It should add an item named "Import Cut List" to the Plugins menu in SketchUp.
This is written to import a csv, not an xlsx, so you will need to save your cut list that way first. xlxs is just way messier than csv, so I took the easy way.
This creates Components, not Groups, and spaces ComponentInstances out along the green (y) axis. I found that piling them all at the origin was hopelessly messy!
This ignores the material field (because there is not enough info to create a material). It also generates only quantity 1 of each part, though that could be changed fairly easily. All your examples were on Layer0, so I didn't co anything to create layers or place things on them. That also could be changed easily enough.
Steve
-
RE: Import A Cut List
@vigy said:
Steve, thanks for your response!
My priority is to have simple rectangular boards, but I never wrote anything in Ruby so it's not that simple for me. and yes it would be nice to have them separated (I didn't want to complicate things)
Victor
I'll take a shot at it when I get a chance. Do you have a sample file you could upload?
Steve
-
RE: Import A Cut List
@vigy said:
Yes Dave, all dropped at the 0 origin is perfectly fine, I'm trying to import a Cut Rite program part list and then assemble it in SU.
Are all the parts simple rectangular boards? If so, it shouldn't be at all hard to write a Ruby to import them. If not, I'd need more info regarding what other shapes are possible - are there curved pieces? is there joinery on the ends? etc. Rapidly gets much more complicated.
Unless there aren't very many parts, piling them on top of each other at the origin would make it pretty awkward to grab them for assembly. I'd think it would be easier if they were separated, even though that would take up more space initially.
Steve
-
RE: Reflect/mirror details at both ends of symmetrical parts
A key question is whether you are finished drawing one end and just need symmetry at the other end, or if you intend to continue editing the first end and expect the other end to mirror it.
For the former, you can simply select the relevant Edges and Faces at the first end, move a copy to the other end, flip it, and drop it in place. Often you will need to clean up a stray Edge or two or repair a Face if you do it that way, but it is fast and easy.
For the latter, though, you need to do something like Dave describes because you need both ends to be instances of the same ComponentDefinition, just flipped. But you will have to explode the board and the ends and then recreate the board as a single component when you are done else you will get the kinds of cut list issues he describes.
Steve
-
RE: Between different Macs plugin works and doesn't work
@ppoublan said:
Dear all,
maybe nothing to do with this issue, but just fixed a bug with plugin and Mac and did not find the reason, just a workaround I want to share :
multiple calls to window.location worked fine on PC, but on Mac only the last call to window .location were received by SU from the webdialog.
Replaced all the window.location from Javascript by SU calling webdialog.get_element_value and this worked.
Yours
PascalWhat you describe is a consequence of the well-known way that javascript calls to Ruby are asynchronous on the Mac. We discussed this in the thread with Garry K, and he is aware of the possibility. But the topic here is a different mystery: Garry's plugin makes connections to his site over the internet, and on some Macs these connections fail while on others they work fine. The failures seem somehow connected with Mountain Lion.
-
RE: How to tell if a plane is horizontal
@jolran said:
Can't one compare against Z_AXIS ?
Yes, Z_AXIS is just a pre-defined Vector3d oriented z-wards.
@jolran said:
Come to think of it. If using a sectioncut all geometry will be on same plane. And "probably" contains faces which could be used to extract a face normal. So a plane might not even get into use. Just compare face normal against Z_AXIS ?
Jeff
A SectionPlane has an associated Plane, and that is all about the plane that is accessible from Ruby. It is returned by SectionPlane#get_plane as a 4-element Array. The first three elements are the components of the normal vector to the plane, and the fourth is the offset of the plane from the origin along the normal. So, you could form a Vector3D from the SectionPlane's normal and compare with that.
However, you should realize that a SectionPlane is a display animal only - the edges you see displayed are not DrawingEntities and do not exist in any Entities collection of the model. You will not find any Faces to use for determining normal vectors! There are plugins that will generate the DrawingEntities of the cut, but this is not done by a SectionPlane.
Steve
-
RE: Between different Macs plugin works and doesn't work
Peculiar indeed! I have only a Mavericks box, so I can't test this. Have you checked the Console log for errors? Seems ironic, as most of the complaints these days are about things not working in Mavericks that were fine in 10.8.
Ultimately, we will have to rely on Gary K to debug this. His source code is scrambled and only he knows quite what it does.
-
RE: How to tell if a plane is horizontal
The Geom::Vector3d#== already accounts for floating point tolerance. So, you should create a z-oriented Vector3d and compare it to the normal of the plane using ==. You should not test it to see if x and y are zero and z is 1.0, as that will not account for tolerance.
-
RE: Exposing Ruby Code?
No, alas, SketchUp does not provide a debugger or trace facility. If the Ruby code prints any output or raises any exceptions you will see them in the console, but nothing more. This has for a long time been the hardest part of developing plugins for SketchUp.
Steve
-
RE: Inference Symbol Size
@matheusbragagnolo said:
Yep, it's a Retina display!
I thought it could be due to it, but was not sure.
Thank youYeah, the adaptation of SketchUp to the Retina was a mixed bag. Some things are wonderfully clear, but others are so tiny they are hard to see. I often find it hard to make out a selected Edge or to be certain that a cursor's hotspot is on an Edge. Fredo has been tearing out hair trying to make view.draw_text use a non-microscopic font. The programmers did not expose any interface to let users configure these things...
Steve
-
RE: Ruby script to output outer face loop?
@emptyvessel said:
I think you gentlemen may be giving me too much credit for my knowledge of ruby.
I am a rank beginner and do not get everything your are saying or showing in your snippets.slbaumgartner: your code still displays a arccurve message for all facets of the arc.
How is "next if used_edges.index edge" suppose to remove edges from consideration?tt_su: Your code fails to run at all. "EdgeUses not found"
Would you be so kind as to explain how each line of your snippet works.Regards,
Hmm. I edited my post after I found errors (typed too fast) - did you try the latest version? I drew a rectangle, changed all the corners to arcs, and ran this and it report four Edges and four ArcCurves... When it completes it dumps a whole Array of stuff on the Console, but that is just because Ruby always returns the last thing it evaluated and I didn't bother to stop it.
If you have a specific example skp, please post it and I'll try to see what went astray.
Also, it looks to me like TT also typed in haste. I don't think his code is right...for instance edgeuses is undefined!
Steve
-
RE: Web dialog on a Mac
This raises an interesting question: does feet&inches also fail on Windows? In other words, is this really a Mac issue at all, or did we just get unlucky (or, if you are trying to eliminate bugs, lucky)?