🏢 PlaceMaker | 25% off for February including new Google Earth data imports! Learn more
  • SketchUp API Blog - Extensions

    7
    0 Votes
    7 Posts
    161 Views
    Dan RathbunD
    @aerilius said: Since I'm relatively new to ruby/plugins, I haven't yet dared to propose SketchupExtension in the Plugin-Installer-Tool discussion, I did. I asked Dana to have a look at my example, in another topic. @aerilius said: ...but also because I had the impression that in its current state, it is neither useful to users nor was I sure whether it's well designed (I can not really judge about that). Well, there is a difference between the Ruby functionality, and the Application UI functionality. Most users hate the Preferences dialog panel interface, for several reasons: Too small, only shows limited number in the list.* Panel cannot be sized.* The amount of attribute data displayed is fixed.* The list cannot be sorted (it's shown in load order.) Now... the Ruby functionality issues (or short-comings,) have prevented others from creating a better manager. The most glaring is the one Dana is working on, that is "one-click" installation and updating. This is also the number one complaint. @aerilius said: I think it's important for this discussion that we know if it's necessary to invent our own "standard" how to manage/disable plugins, It's more important that rubyists use a common class, that can be extended. For instance, we already have the issue where some plugins are Smustard Organizer compatible, but not SketchupExtension compatible, and visa versa. There are quite a few plugins (a most all of the Google authored plugins,) that already use SketchupExtension class instances. It does make sense not to orphan them. @aerilius said: or if SketchupExtension could once become a serious possibility (with some overhaul ). YES, and I've already done an overhaul, for my own use, and proved to myself that the class can be improved greatly (and the few current bugs fixed.) BUT.. I don't "own" the class, it's a standard API class, so I can't release the code. I have about $2500 labor into it, and was wondering, if anyone would be interested in donating toward it. If a "donation piggybank" reached that amount I'd release it. (I wonder if I can convince 100 people to donate $25, or 2500 to donate a buck?)
  • Unicode characters problem

    9
    0 Votes
    9 Posts
    265 Views
    voljankoV
    The problem was in the file,not in the code. I have saved the file in notepad as UFT-8 ,so I can "unpack" the character. I have tried to save the file in other formats (unicode,ANSI,unicode big endian) and is always giving me errors. So only UFT-8 is ok. Problem solved
  • Methods from Support files

    6
    0 Votes
    6 Posts
    204 Views
    TIGT
    Moved.
  • Ruby How to Select All Connected

    6
    0 Votes
    6 Posts
    2k Views
    TIGT
    I've moved this into the Developers' Forum as it's a general issue... You can get info about a curve. verts=curve.vertices returns the vertices, so if it's an arc etc then vf=verts.first and vl=verts.last are the end vertices. You can also get the start and end edges with ef=curve.first_edge and el=curve.last_edges You can get the edges that use any vertex with edges=vertex.edges so do that for vf and vl in turn - the array of edges will include the curve's edge so fedges=vf.edges; fedges.delete(ef); fedgeyouwant=fedges[0] ditto for vl/ el So you now have a way to find the two edges connected to ends of an curve. This assumes you have checked it's a curve, it's not looped etc; and if there isn't a connected edge you get 'nil'. or if there are more than connected edge then only the first one found is returned...
  • Web Dialog not firing a JavaScript function...

    14
    0 Votes
    14 Posts
    3k Views
    thomthomT
    Yes, one has to use a combo. If you look at the jQuery source you see the various methods they use to make it cross platform compatible. onReadyStateChange is used as a fallback for older IE versions. Mozilla, Opera, Webkit and newer IE use DOMContentLoaded. http://ie.microsoft.com/testdrive/HTML5/DOMContentLoaded/Default.html
  • How can one calculate the smoothness of a bezier curve?

    11
    0 Votes
    11 Posts
    602 Views
    thomthomT
    @mac1 said: What criteria is used to determine smoothness is good enough?? RMS error or?? I was thinking that, from a user's point of view, one set a max angle. That the segments connecting each other would not exceed this max angle. Though, I am open to other definitions.
  • How to convert String to Path?

    10
    0 Votes
    10 Posts
    915 Views
    TIGT
    Thomthom you are right! Here is a fixed version if (pth=model.path).empty? ### do stuff with an alternative path else ### do stuff with 'pth' as it's not empty end
  • Bug Splat on erase!

    11
    0 Votes
    11 Posts
    418 Views
    voljankoV
    But also Dan's suggestions have positive results: In the activate method of the tool I have put the Sketchup.active_model.start_operation "myTool",true,true,false And I have put the Sketchup.active_model.abort_operation in the deactivate method of the tool and in the onPreSaveModel model observer. Now the group is disappear before saving the model. Thank you both.
  • Copy selection to new group?

    8
    0 Votes
    8 Posts
    2k Views
    TIGT
    Once you have the group you can get a reference to its definition defn=group.entities.parent It acts just like a normal component definition. So then use group2=model.entities.add_instance(defn, group.parent.transformation) [you must check it's not already in the model - if it is use group.transformation] then group.erase! So the collection is now called ' group2' and it is in model.entities...
  • Model observer problem

    3
    0 Votes
    3 Posts
    223 Views
    voljankoV
    Yes,I have thought about this right after sending my post,but want to test first. Now it is working ok and sorry for blaming observer for this problem. So this is the working code: class MyModelObserver < Sketchup;;ModelObserver def onPreSaveModel(model) UI.messagebox("onPreSaveModel; " + model.to_s) end end # Attach the observer. Sketchup.active_model.add_observer(MyModelObserver.new) class MyAppObserver < Sketchup;;AppObserver def onNewModel(model) UI.messagebox("onNewModel; " + model.to_s) Sketchup.active_model.add_observer(MyModelObserver.new) # Here is where one might attach other observers to the new model. end def onOpenModel(model) UI.messagebox("onOpenModel; " + model.to_s) Sketchup.active_model.add_observer(MyModelObserver.new) # Here is where one might attach other observers to the new model. end end # Attach the observer Sketchup.add_observer(MyAppObserver.new)
  • Mouse Capture (Win32 API)

    13
    0 Votes
    13 Posts
    4k Views
    M
    So here is the jist of Anton's code: Capture mouse (Sketchup will stop reacting to it): getForegroundWindow=Win32API.new("user32", "GetForegroundWindow", [], "L") Win32API.new("user32", "SetCapture", "L", "L").call(getForegroundWindow.call()) Read all key states (keyboard and mouse): @getKeyboardState=Win32API.new("user32", "GetKeyboardState", "P", "V") @lpKeyState=" "*256 @getKeyboardState.call(@lpKeyState) @lpKeyState will hold an array of 256 numbers for all the keys. @lpKeyState[1,2,4] - [1]left-mouse, [2]right-mouse, [4]middle-mouse @lpKeyState[48..57] - keyboard keys 0 to 9 Release mouse Win32API.new("user32", "ReleaseCapture", "V", "L").call()
  • Parent instance of a component

    13
    0 Votes
    13 Posts
    1k Views
    voljankoV
    My intention was to write and read some attributes to some groups and components. After writing it to components (instances) ,it was impossible to read the attribute of the parent component(or group). To resolve it,I have decide to write and read only to definitions of the components. Now,before I write or read to entities, I check if the entity is group or component. If it is a group,I read and write to this entity,if it is a component,I read and write to the definition of this component.In this way,I don't need to know the exact parent instance of the component,because all the instances have the same attributes. So the problem is resolved
  • Distortion?

    5
    0 Votes
    5 Posts
    263 Views
    P
    I think I found a way to do it =). I just project the geometry onto a curved surface. Than I export the view as 2D dxf. So,the imported dxf contains the distorted geometry. The distortion value can be controlled by the fov of the camera.
  • Issues with the onMouseMove method within a Ruby Tool

    7
    0 Votes
    7 Posts
    435 Views
    TIGT
    Why ask me? You are the one with all of the code... Just test it. You need to call your method self.draw_beam() within the onMouseMove method - probably after you've test for a certain 'state' being reached - e.g. perhaps initially 'draw_beam' doesn't kick in with @state=0, but after you have done some other stuff when you've then set @state=1 - then in the onMouseMove method the line would be self.draw_beam() if @state==1 etc, later on, perhaps after you click again, you'd set @state=2 so then the 'draw_beam' stops...
  • Getting SketchUp to play nicely with RubyGems?

    24
    0 Votes
    24 Posts
    5k Views
    Dan RathbunD
    @unknownuser said: Ruby LOAD PATHs script for (Win32)](http://forums.sketchucation.com/viewtopic.php?f)":1xbd78u2] I am trying to write a plugin for sketchup 8 using rubygems. ... About the initial load error now, whenever I uncomment the #$LOAD_PATH << "#{pre}/site_ruby/#{ver}" line (the directory containing the rubygems file among others), sketchup crashes during launch. It is NOT likely you will get a standard RubyGems to work with Sketchup. One problem may be that RubyGems redefines the Kenel.require() method, which is inherited by Object, and so inherited by all other Ruby objects. For info on RubyGems, see the Resources list under the section: TECHNICAL REFERENCES It is more probable that a special version of RubyGems would be needed for use under Sketchup.
  • How do I raise a number in a loop?

    6
    0 Votes
    6 Posts
    171 Views
    Dan RathbunD
    @pixero said: Ok, that make sence. Following Jims example would it be something like: att = 0 > ary.each { |item| > item.set_attribute("Dict Name", att) > att+=1 > } 1) There's a parameter missing in set_attribute, the 3rd arg is the value argument to assign to the attribute. (Would the example assign nil, or would an ArgumentError be raised?) 2) The examples will begin at 0, not 1. (You could adjust the start ordinal for var att in it's assignment statement.) 3) Be sure the array is sorted first the way you wish to have the attributes numbered. You may need to write your own sort method if the objects in the array are complex objects, such as Drawingelement subclasses. Meaning you may wish to sort by some property of the object, such as it's height above the XY plane (just as an example.) 4) Whenever you need to iterate an enumerble Ruby object, you can use the each_with_index method (that is inherited from the "mixin" module Enumerable.) Here I add 1 to the index, so the numbering starts at 1: dict = "My Dictionary Name" val = "some value" ary.each_with_index { |item,pos| item.set_attribute( dict, pos+1, val ) } If you still wish to use 0 padded string attribute names: dict = "My Dictionary Name" val = "some value" places = 6 ary.each_with_index { |item,pos| item.set_attribute( dict, (pos+1).to_s.rjust(places,'0'), val ) } Note: The 2nd arg in rjust, the padstring, is optional and defaults to a space character.
  • Intersecting 2 Groups Question

    13
    0 Votes
    13 Posts
    302 Views
    jolranJ
    OK. thanks. I have missed the notes part.
  • BUG: WebDialog conditional comments

    4
    0 Votes
    4 Posts
    287 Views
    AdamBA
    @thomthom said: @adamb said: Rather annoyingly, if you have IE9 installed, looks like SketchUp somehow thinks its running IE7. It doesn't think - it does. Embedded web controls are handled differently. You must force it to use a different version. The thing that threw me was that SU and IE8 installed correctly reports IE8, as does IE7 and IE6 with the same html. IE9 does not. But given the conditional comments are being dropped by MS for IE10, and frankly anyone still use IE6 or IE7 is living on borrowed time, I've ripped out all the conditional stuff. thanks for the all the info though.
  • How to check registry for pro version?

    6
    0 Votes
    6 Posts
    202 Views
    M
    @jim said: TIG, what if the user installed Pro, then let it expire? Does the Pro reg key still exist? I think it might. I just tested that. It seems the registry keys get deleted if you uninstall SU Pro. I will use this to check for my program. It's not ideal, since you could probably have a pro version running as a free version, but better than nothing Thanks!
  • Strange result of a substraction

    14
    0 Votes
    14 Posts
    220 Views
    thomthomT
    http://floating-point-gui.de/

Advertisement