You should post this request in the Developers Fourm
Posts
-
RE: HTML export with hotspots?
-
RE: Aliasing UI::messagebox ?
@unknownuser said:
... I tried various flavors of the alias and alias_method keywords, but those don't seem to work with modules. I'm certain there's a way to do it, but I thought I'd ask here before diving into my Ruby books.
Yes.. it's weird that alias doesn't work with modules.
But this is even weirder. To alias modules, you instead use the object= method.
Example aliasing of Sketchup module: (At Ruby Console type the following, where ">>" is resulting output.)
Sketchup.class >> Module Sketchup.object_id >> 43353420 # remember this id... # now alias the module SU = Sketchup >> Sketchup SU.class >> Module SU.object_id >> 43353420 # it's the SAME exact id # test it... SU.version >> 7.1.6087I would think that we must be careful what namespace the alias constant is declared within. If the above statement "SU = Skecthup" was declared inside a module, or a class, it would only be accessible within that namespace, or must be qualified to be accessed.
For example, say you used that alias assignment within a module named "Configurator", in order to access the alias from outside, you'd need to qualify it with:
Configurator::SU.methodcallHowever.. if you wished the alias to have global public access, you'd need to declare it outside ALL modules, in the objectspace. (Similar to typing it at the console.)
BUT... what if for control purposes (ie, conditional loading,) you needed to have the statement inside a class or module?I think in this case, remember the Kernel.eval() method, and the fact that module Kernel is included in every object. That means that the containing module has it's own copy of eval. So you cannot call just eval (unqualified,) because you'd be calling the local module's copy of eval.
To do it from within a module (or class,) you must qualify the call:
if situation then Kernel.eval("SU = Sketchup");
Then the alias constant is global. -
RE: New API doc - typos and questions
The class Sketchup::HLR is undocumented in the API.
It's an Entity subclass.
It inherits all the Entity baseclass methods, and adds 2 of it's own:- .calculate* .num_faces
If you create a HLR object at the console, and call .parent (when it has no parent) a BUG SPLAT! results. See post: http://forums.sketchucation.com/viewtopic.php?f=11&t=24740#p212101
What is this class HLR used for? (.. as there is no .add_HLR method for the Entities collection object.)
-
HLR.parent BUG SPLAT!
HLR.parent BUG SPLAT!
The HLR.parent method does not have error handling to trap when the object is not yet attached to a collection or other object.
If .parent is called on any HLR class object before attachment, a BUG SPLAT! results.
The method should either return nil when it has no parent, or raise a proper Exception. In both cases the $! error message should be set to some meaningful string, ie: "Nesting Error. No parent object..." (or similar.)
Platform: Win32
Sketchup: 7.1.6087--report--
At Ruby Console:
var=Sketchup::HLR.new
var.parent
--> BUG SPLAT!I have no idea what an HLR entity subclass is used for! It inherits all the Entity baseclass methods, and adds 2 of it's own, .calculate and .num_faces
The Sketchup::HLR class is undocumented in the API. -
RE: Tool History Dialog/Recall?
@earthmover said:
Would it be possible to create a dialog window that shows the a running tab of the last 10 or so tools or plugins used and allow you to recall them?
The $" array holds a list of every ruby script that was loaded by the require command, but those scripts are usually ones we only wish to load once anyway. (Which is the purpose of the array in the first place, require checks the array so as not to reload scripts that have already been loaded.)
I say this because, the feature you desire would need a similar array, but it must have all files loaded by the load command, except those that are in the $" array. (Tricky because require passes it's file argument to load if it decides a script needs to be loaded.)
I hate to think about this, but one solution would be to override load; not desirable because it's already been overriden by Google to handle the .rbsfiles.
It may be better to create a new run command, that mantains the 'history' array and then passes the filename argument on to load.
So the 'rule' would be if you want a script in the history, use run, if not use load directly.
A webdialog could be made easily once the maintenance of the history array was solved. Heck.. even a Inputbox with a dropdown list would work, but a webdialog would be better (single click and it could remain open, the list could be updated continuously. An Inputbox would be 3-click, open it choose script, click OK.)
-
RE: {REQUEST} Import Vectorworks 3D geometry to SU !!!
@thinkbuild said:
- on a VW2010 thread over at pushpullbar, it was suggested to goto .kmz via google earth and then hack out the kml file ... But I couldn't figure that out with google earth. sigh.
Sketchup 7.1+ has built-in Import directly from .kmz and .dae (Collada)
Menu: File > Import...
Change file type to (.kmz,.dae) and choose the file.
-
RE: Problems with Sketchup Classes
@l.frisken said:
I could only get the "testing" method to work when i called it from an instance of the class (that I created) myself:
That is correct. Most methods of classes are instance methods. You should be able to call them from inside the class (ie another method of the same class,) using it as a private method.@l.frisken said:
anyway, to cut a long story short I finally cracked the code on how to get yaml to work with sketchup objects (so I thought):
class Sketchup;;Geom;;Point3d > def initialize(x, y, z) > super() > @x = x > @y = y > @z = z > end > endIt seemed as though the Point3d class did not even have instance variables (weird!), I can only assume that this is because they were created from the closed side of Sketchup.
Ignoring the nesting error (that ThomThom pointed out,) the other error is that you are calling super(). Why call the superclass ? I think Google boo-booed and made Point3d a subclass of Object, when they should have made it a subclass of Array.
Anyway besides the fact that your override is erroneous, and does not account for the variable argument list (ie: you can pass 1 object in such as Vector3d, or an Array [of 1 to 3 Numerics,] OR 1 to 3 Numeric arguments.)IF your not going to handle the argument list, then you must let the embedded API object do it. But you DON'T do it by calling super(args) because that just passes the argument list to class Object.
[IN your example above, what your super() does is actually call Object.initialize() without actually passing the argument list. Also in many cases .initialize* is set private, and you can't call it directly from outside a class; instead you normally call the public method .new from outside a class. ]
You must FIRST alias the class method so the original code can be called, THEN redefine the class method using the oldname. alias_method :newName, :oldName
Example:module ;;Geom class Point3d(*args) alias_method(;orig_new,;new) def new(*args) pt=orig_new(*args) # You could add some values the args array args << "My Point3d class Overrride" # .new automatically calls initialize(*args) # before returning the object handle. return pt end def initialize(*args) # prior to initialize, .new has already # created the Point3d object. # @x,@y,@z should have been setup by .new puts args.last # should print string added in .new end end # class end # module(It's possible initialize may get called twice in above example)
You can do anything you want FOR YOUR OWN USE.
BUT Google OWNS the Sketchup, UI, and Geom Namespaces. The Terms of use prevent you from causing other people's installations of Sketchup to be degraded or broken or such. The license agreement is at: http://sketchup.google.com/intl/en/download/license.html
At the very least, if you wanted to extend Sketchup classes (and release those extensions,) you'd need to have Google Sketchup Team consent AND Sketchup Developer Community approval.
You might join the SKX project, or monitor the SKX forum.You'd need to make a very good case for extending the SU classes with the community, especially if it can be done quite easily without extending them.
Example. IF the yaml lib already provides String.to_yaml, and most Sketchup classes provide SUclass.to_s, then you have conversion by using SUclass.to_s.to_yaml
-
RE: Unit Testing, Test-Driven Development?
@jim said:
... but how to incorporate it into the development cycle without imposing a performance penalty in the release version?
Definately, any Test or Debug module would be something we would ONLY load during testing.
We should not expect someone (ie the average user,) to have those modules loaded when they are just running and using Sketchup and the plugin (once it passes tests and is released.)
If you were testing a plugin on a model that was very big and had alot of textures, I'm sure performance would be reduced. That's only during testing tho.
Another option, is to cut up a Test or Debug module into smaller modulettes so only that which a tester needs is loaded. Perhaps take advantage of the autoload method, to do it automatically.
-
RE: Unit Testing, Test-Driven Development?
@jim said:
... into the SketchUp/Ruby environment, ...
- Could we use acronym 'SURE' (SkethcUp Ruby Embedded,) to refer to how Ruby is set up to operate under Sketchup, in contrast to how Ruby operates under the Standard Installation?* This is different from the SUAPI, which is how Sketchup simply extends the Ruby langauge (base classes) and adds it's application dependant Modules, Methods and Classes (which any script can do, even in the Standard Environment.)
@jim said:
... I'd like to know if I'm asking the right questions?
IMHO they appear to be vaild questions.@jim said:
I'm interested in a more fundamental conversation to answer the question of how testing might be used to make writing and debugging SketchUp/Ruby code more efficient;
I am definately all for this!
I was playing around trying to get ALL errors to appear in MY error messagebox instead of the tiny postage-stamp sized one SU implements. It works only if I specifically call my ErrorBox method (from say a rescue clause, or a "if $DEBUG" statement.) But it doesn't work for the load method, even if I try to override it, because I think SU has already overridden it, (to accomodate the decrypting of .rbs files,) and aliased the original as "_load". So I still get the kwappy "Load Error" dialogs. Hmmm... I never did try to override _load, maybe that's the answer. I'll have to try it.@jim said:
... if it might be a good idea to incorporate the unit test suite files from the Ruby language install into the SketchUp/Ruby environment, or perhaps if a small library should be written specifically for SketchUp/Ruby?
I haven't yet studied these standard libs.Any tutorials online for using them?
@jim said:
My initial thought is that a few assert statements would go a long way to finding errors quickly, but in a way that amounts to adding type-checking to Ruby values - not a bad idea really, but how to incorporate it into the development cycle without imposing a performance penalty in the release version?
- I definately don't want Ruby to be anything like Ada where even two strings of different lengths are considered different 'types'. (In Ada, you can't even compare or concatenate them without type converting one to the other's type.)
- On the other hand, when types are too loose, it results in lazy and poor programming practices. (There are many examples of methods in the SUAPI that should have raised proper Exceptions when unsuccessful, but instead take advantage of Ruby's loose typing, and simply return nil. This technique is used for lazy conditional expressions because Ruby's NilClass is compatible with FalseClass in boolean expressions. This often results in the situation where we don't know why a method failed because there often are several failure modes.)
-
RE: Unit Testing, Test-Driven Development?
Daniel J. Berger and Park Heesob, the guys who do the new Win32::apisuite[*], have a 'techique' of doing testing, using a Test module(s).
If you download some of their code packages, have a look specifically at the 'test' folders, and scripts. Should be informative. These guys work on the Ruby Core also I believe, so they know their stuff. Daniel at least is also a developer/administrator on RubyGems, Rdoc and Ruby/DBI.
Their RubyForge page: http://rubyforge.org/projects/win32utils/[*] Win32::API is a newer replacement for the OLD 1.6.x Win32API.so and has many improvements, supports callbacks, etc.
-
RE: Feasibility of this occurring?
I posted an informative reply on this topic at the Sketchup Developer's Google group.
(I guess I'll just Carbon Copy it here.)@unknownuser said:
Is there any possibility of using Google Sketchup within a website ...?
GoogleGroup Topic: To Run Google sketchup within websiteI believe you must export models as Collada(.DAE) files for use on websites.
The website would use Google O3D pluginto VIEW the model.
Visitors would need to download and install the plugin.
Interaction can be done on the model by the website visitors, thru Javascriptprogramming. Such as changing colors, or materials, moving objects around, etc. But all these things I think must be drawn in Sketchup.There is no basic editing / modeling capability in O3D. Only manipulation of components.
O3D Technical Overview
http://code.google.com/apis/o3d/docs/techoverview.htmlO3D Developer's Guide
http://code.google.com/apis/o3d/docs/devguideintro.html
Working Webpage Examples:
Smart Designer by SmartFurniture.com
http://www.smartfurniture.com/smartdesigner
Smart Designer
is a new online application that enables consumers and businesses to design and order their own furniture products. They can then interact with those customized products in the context of a 3D space that simulates their homes or offices.Home Configurator (Firefox only)
http://o3d.googlecode.com/svn/trunk/samples/home-configurators/homedesigner.html.
-
RE: STD IO .isatty produces BUG SPLAT!s
@andrews said:
Next time this happens, when you fill out the Bug Splat report, put in some sort of keyword ...
I think I did, did I not do both?
My post here IS the followup.
In each of the 4 explaination(s) in the Bug Splat! reports, I wrote almost identical notes (but the receiver of the ".isatty" method changes per the list at the top of this thread.):
@unknownuser said:Ruby Console:
$stdin.isatty
--> BUG SPLAT!
So take your pick, try searching on ".isatty"Not that important anyway.
Interesting that $stdout and $stderr raise "NoMethodError: undefined method `isatty'"
The
Sketchup::Consoleclass needs a major overhaul.
We need to be able to use STDIN, STDOUT and STDERR to implement our own Console Applets / Debuggers, or integrate with thrid-party Ruby IDEs.
There is a glaring 'perfect' space for controlling such a feature on the 'Applications' page of the 'Preferences' dialog. -
RE: Observers WhishList
there is NO
**Sketchup::StylesObserver**But the Styles class has a few 'observer-like' methods:
Styles.update_selected_style
This method is a boolean method (which should have a '?' at the end of it's name.) The use of this method is confusing (partly as the example does not show the style being selected.)
Styles.active_style_changed
(again, should have a '?' at the end of it's name.)
This is a session boolean, changes anytime after saving; but no way to trigger an event.Would it be better to create a StylesObserver class?
That had methods such as:
--- (edit) names changed
onStyleSetAdd(styles, newStyle)
onStyleSetCreate(styles, newStyle, fromStyle)
onStyleSetChosen(styles, oldStyle, newStyle)
--- (edit) name added
onStyleSetRename(styles, style, oldName, newName)
onStyleSetRedescribe(styles, style, oldText, newText)
onStyleSetEdited(styles, style, styleOptions, optionsChangedHash)
(for Bulk handling instead of single option handling.)Purge methods
(as in previous post (Suggested) onBeforePurge & onAfterPurge)
onBeforePurge(styles, stylesUnusedObjectArray)
onAfterPurge(styles, removedStylesArray, purgeResult)--- (edit) the following withdrawn
onStyleEdit(styles, style, option, oldValue, newValue)*****- probably will need to implement a "StylesOptions"
OptionsProvider
-- in favor of updates to
RenderingOptionsObserveras in post:
Re: StyleOptions / StyleOptionsObserver
- probably will need to implement a "StylesOptions"
-
RE: Observers WhishList
@thomthom said:
@whaat said:
... For example, OnEntityChanged, what constitutes a 'change'?
Yea - I spent some time on this because I was setting attributes - which seems to be a change. Not sure if I want that to trigger. At least not most of the times. attributes are like meta data.
maybe onChange for geometric changes, andonAttribChange(dict, key, oldVal, newVal)for the attribute meta data?Do changes to an Attribute currently fire onEntityChanged events?
What about adding or deleting an attribute from a Dictionary?
What about adding or deleting a Dictionary from an Entity? -
RE: Observers WhishList
@dan rathbun said:
there is NO
**Sketchup::StylesObserver**Made a few edits to proposed methods.
see original post: StylesObserver -
RE: Observers WhishList
@tig said:
- the current Render Settings are temporary changes in that View not the Scene's defined Style - if you change back to that Scene tab the Style should be refreshed back as it was until you save its changes - I know that Xray mode is perhaps a bad example in that it transcends Style settings.
My point is that what is being Rendered in a View and a Scene's Style are different things. One is transient, one is fixed.
I don't see any difference in practice.
I have 4 scenes tabs defined and have the Style dialog open in the edit pane.Whatever I change in the Style dialog changes on the App toolbars or menus.
Whatever I change on the menus (ie Hidden Geometery,) or toolbars (shaded, xray, wireframe etc.,) is immediately echoed in the Style dialog Edit pane.
After making changes, switching between Scenes makes no changes, however I suppose all scenes are set to the same Style.
If I purposely try to set one scene to a different style, it changes, then I switch to another scene it switches back; returning to the previous scene (which I had changed does not change the Style.) It seems there is a default Model Style.
This is confusing.
-
RE: Observers WhishList
@tig said:
Therefore shouldn't there be two sorts of Observer - one to watch for changes to the "Rendering Options Settings" and another to watch for "Style Changes"

Yes possibly. The API is WAY out of date on this subject and not very clear.
Likely that Rendering Options came first (before Scene Styles were 'invented'?)
@unknownuser said:
(in regard to Rendering Options) The majority of the rendering information returned exists in the Model Info > Display section of SketchUp
But that is no longer true!
There is no 'Display' section in the Model Info dialog in 7.x! -
RE: Observers WhishList
@thomthom said:
Before, Styles where called Rendering Options. So look at the
RenderingOptionsclass. You have aRenderingOptionsObserverclass: http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/renderingoptionsobserver.htmlOK looked at that... seems like the
RenderingOptionsObserverclass needs an overhaul:- Need to alias (rename) as:
StyleOptionsObserver* Need to deprecate the old name.
@unknownuser said:
The type is an internal number that indicates what was changed. You will need to watch the observer for numbers you are interested in.
- That is clumsy! (or lazy programming.) Ruby is a high-level language, lets have the same identifier keys as used in the
RenderingOptionscollection class.*RenderingOptionsalso needs to be aliased or renamedStyleOptions.* Need to deprecate the old name.
This only covers the onStyleEdit method I proposed in the previous post, which is actually namedonRenderingOptionsChanged, however, it fails to send any detail, it only tells (by ordinal,) what options WAS changed. I think it should pass oldValue and newValue as well.
So reproposing the method as:
onStyleOptionsEdit(styleOptionsCollection, optionKeyname, oldValue, newValue)
Could still have old method that sends ordinal number, as:
onStyleOptionsChange(styleOptionsCollection, optionNum)- Need to deprecate the old name.
STILL, need as in previous post, a 'higher' level
StylesObserverfor triggering events when Styles are manipulated as a whole set (saved to, or loaded from files.) We can call these a StyleSet.- It is possible that those methods could go in the
AppObserverrather than create a new observer class.
- Need to alias (rename) as:
-
RE: Skp file format to carry keywords (tags)
The 'Redefine Thumbnail on Save' control checkbox is in an unnatural location (at least in my opinion.) It is currently on the 'File' page, of the 'Model Info' ToolDialog (beneath the 'Description' textarea.)
This space (on the ModelInfo dialog,) could be better used for text input controls for the
Model.nameandModel.tagsattributes (which it seems can currently only be set thru rubyscript.)
THIS thread should discuss where the**Model.name**and**Model.tags**attribute edit controls should be located, and the use of these attributes.It would be better (or more natural) if the 'Redefine Thumbnail(s) on Save' checkbox, was located on the 'General' page, in the 'Saving' section, of the 'Preferences' Dialog (ie: it would/should be a global setting for all models.)
To discuss where and if the 'Redefine Thumbnail on Save' control checkbox should be / or shouldn't be moved to / or IF it shouldn't be moved / and whether it should be a global setting for all models (or not.) Please go to thread: "Thumbnail Checkbox / Model.name / Model.tags" -
Thumbnail Checkbox / Model.name / Model.tags
The 'Redefine Thumbnail on Save' control checkbox is in an unnatural location (at least in my opinion.) It is currently on the 'File' page, of the 'Model Info' ToolDialog (beneath the 'Description' textarea.)
This space (on the ModelInfo dialog,) could be better used for text input controls for the
Model.nameandModel.tagsattributes (which it seems can currently only be set thru rubyscript.)
To discuss where the**Model.name**and**Model.tags**attribute edit controls should be located, and the use of these attributes, please go to thread: "skp file format to carry keywords (tags)"It would be better (or more natural) if the 'Redefine Thumbnail(s) on Save' checkbox, was located on the 'General' page, in the 'Saving' section, of the 'Preferences' Dialog (ie: it would/should be a global setting for all models.)
THIS thread should discuss where and if the 'Redefine Thumbnail on Save' control checkbox should be / or shouldn't be moved to / or IF it shouldn't be moved / and whether it should be a global setting for all models (or not.)