⚠️ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

Alkategóriák

  • No decscription available

    20 Témakörök
    462 Hozzászólások
    HornOxxH
    @pilou said: More appetizing in chocolate! Eggs are good as well - but only very fragile when falling down in SketchyPhysics
  • Function to draw 3d text via ruby

    6
    0 Szavazatok
    6 Hozzászólások
    1k Megtekintések
    C
    entities.add_3d_text. This function I am needed. Thank you.
  • Screen Coords

    9
    0 Szavazatok
    9 Hozzászólások
    611 Megtekintések
    A
    Okay, Thanks
  • Exportvertices2csv.rb as a teaching material

    5
    0 Szavazatok
    5 Hozzászólások
    548 Megtekintések
    T
    Thankyou all! The problem was solved. Dan Rathbun Do you mean the whole class "Exportvertices2csv" should be a module? Or, the instance method "printcsv"should be a module?
  • Test Point3d position tolerance?

    6
    0 Szavazatok
    6 Hozzászólások
    485 Megtekintések
    AdamBA
    sure, but if the transform bumps you out of the SU tolerance, you're hosed.
  • Start/commit_operation

    12
    0 Szavazatok
    12 Hozzászólások
    2k Megtekintések
    L
    First I guess like the poster I don't really have a point with this rant except to warn others who is as clueless as I about both neccessary and good practices working with Ruby Sketchup. As usual when I read your posts, thank you, I find a gold nugget, it is sometimes just hard to to know that you need it. Second I see that it is good and and I agree it makes sence that it works that way.. My irritation points are that: As far as I know my add_3d_text didn't output any error beside returning a nil value, a return value you seldom use. There was (AFAIK) no type of exception raised either. The documentation is as usual very short and doesn't mention it actually undoing any work, the work might as well have been undone by a call to abort_operation not automatically.
  • Same Face in Group plane not same

    3
    0 Szavazatok
    3 Hozzászólások
    264 Megtekintések
    thomthomT
    When you open a group or component for editing, everything in that context is converted from local coordiantes to global coordinates.
  • WebDialog and OSX - resizeable regardless?

    5
    0 Szavazatok
    5 Hozzászólások
    379 Megtekintések
    thomthomT
    @adamb said: Nice one driven. Just remember this is not supported by SU6, so make sure you predicate it with version_number. Adam Or - as I prefer - by using .respond_to? to instead check if the feature exists. No mucking about with version numbers.
  • Color the DC conditioning on its attributes & values (MYSQL

    23
    0 Szavazatok
    23 Hozzászólások
    2k Megtekintések
    B
    This code finally worked UI.menu("Plugins").add_item('Assesment') { Inspection.color } require 'mysql' module Inspection def self.color dbh = Mysql.real_connect("localhost", "root", "***", "test",3306) dbh.query("drop table if exists inspection") dbh.query("create table inspection(component varchar(20), ID int(4), rating int(1))") dbh.query("insert into inspection values('deck',2345,2),('Substructure',2349,1),('Superstructure',2353,3)") res = dbh.query("SELECT rating FROM inspection where id = '2345'") while row = res.fetch_row do xx = row[0] printf "%s\n", xx end res1 = dbh.query("SELECT rating FROM inspection where id = '2349'") while row = res1.fetch_row do xy = row[0] printf "%s\n", xy end res2 = dbh.query("SELECT rating FROM inspection where id = '2353'") while row = res2.fetch_row do yy = row[0] printf "%s\n", yy end Sketchup.active_model.entities.to_a.each{|e| if e.get_attribute('dynamic_attributes','id','')=='2345'&& xx=='1' e.set_attribute('dynamic_attributes','rating','1') elsif e.get_attribute('dynamic_attributes','id','')=='2345'&& xx=='2' e.set_attribute('dynamic_attributes','rating','2') elsif e.get_attribute('dynamic_attributes','id','')=='2345'&& xx=='3' e.set_attribute('dynamic_attributes','rating','3') end } Sketchup.active_model.entities.to_a.each{|e| if e.get_attribute('dynamic_attributes','id','')=='2349'&& xy=='1' e.set_attribute('dynamic_attributes','rating','1') elsif e.get_attribute('dynamic_attributes','id','')=='2349'&& xy=='2' e.set_attribute('dynamic_attributes','rating','2') elsif e.get_attribute('dynamic_attributes','id','')=='2349'&& xy=='3' e.set_attribute('dynamic_attributes','rating','3') end } Sketchup.active_model.entities.to_a.each{|e| if e.get_attribute('dynamic_attributes','id','')=='2353'&& yy=='1' e.set_attribute('dynamic_attributes','rating','1') elsif e.get_attribute('dynamic_attributes','id','')=='2353'&& yy=='2' e.set_attribute('dynamic_attributes','rating','2') elsif e.get_attribute('dynamic_attributes','id','')=='2353'&& yy=='3' e.set_attribute('dynamic_attributes','rating','3') end } Sketchup.active_model.entities.to_a.each{|e| if e.get_attribute('dynamic_attributes','rating','')=='1' e.set_attribute( 'dynamic_attributes', 'material', 'black') e.set_attribute( 'dynamic_attributes', '_material_formula', '"black"') $dc_observers.get_latest_class.redraw_with_undo(e) elsif e.get_attribute('dynamic_attributes','rating','')=='2' e.set_attribute( 'dynamic_attributes', 'material', 'blue') e.set_attribute( 'dynamic_attributes', '_material_formula', '"blue"') $dc_observers.get_latest_class.redraw_with_undo(e) elsif e.get_attribute('dynamic_attributes','rating','')=='3' e.set_attribute( 'dynamic_attributes', 'material', 'red') e.set_attribute( 'dynamic_attributes', '_material_formula', '"red"') $dc_observers.get_latest_class.redraw_with_undo(e) end } end end Thanks to all.
  • .dll accessing - how to?

    12
    0 Szavazatok
    12 Hozzászólások
    1k Megtekintések
    AdamBA
    Guy, Generally, you're not going to be able to do anything useful with the entrypoints its exposes. Particularly not from Ruby. Not sure if it helps but here's a quick tutorial on output very high resolution hidden line images using LightUp.. http://www.light-up.co.uk/index.php?t=story&p=101 Adam
  • [Code] Image: definition, transformation, transformation=

    15
    0 Szavazatok
    15 Hozzászólások
    6k Megtekintések
    T
    As a 'Thanks!' to Alex and my contribution to wellness of other exporters and especially their developers here is my modified transformation method that works I think in 99.9%. It may fail due to float precision, but I looks it doesn't happen too often. My idea is to calculate a center of the image, based on initially derived transformation and to compare it with a center of bounding box of the instance self.bounds.center. If the points are not same it means that an image is flipped. If flipped, I create a modified transformation with a negative scaling along y axis. Now I realized that this can be done by simply crating a Geom::Transformation.scaling origin, 1, -1, 1 and applying it to the original trans... def transformation origin = self.origin axes = self.normal.axes tr = Geom;;Transformation.axes(ORIGIN, axes.x, axes.y, axes.z) tr = tr * Geom;;Transformation.rotation(ORIGIN, Z_AXIS, self.zrotation) tr = tr * Geom;;Transformation.scaling(ORIGIN, self.width/self.pixelwidth, self.height/self.pixelheight,1) tr=tr.to_a tr[12]=origin.x tr[13]=origin.y tr[14]=origin.z trans = Geom;;Transformation.new(tr) #Global! trans of an image instance #check if flipped center_point=Geom;;Point3d.new(self.pixelwidth/2.0,self.pixelheight/2.0,0).transform! trans #center of an image center=self.bounds.center flipped=(center_point.x!=center.x or center_point.y!=center.y or center_point.z!=center.z) if flipped tr = Geom;;Transformation.axes(ORIGIN, axes.x, axes.y, axes.z) tr = tr * Geom;;Transformation.rotation(ORIGIN, Z_AXIS, self.zrotation) tr = tr * Geom;;Transformation.scaling(ORIGIN, self.width/self.pixelwidth, -self.height/self.pixelheight,1) tr=tr.to_a tr[12]=origin.x tr[13]=origin.y tr[14]=origin.z trans = Geom;;Transformation.new(tr) end return trans end#def
  • Puts current module & method in ruby console

    6
    0 Szavazatok
    6 Hozzászólások
    650 Megtekintések
    M
    Hi Dan and Chris. Thank you for your answers ! @chris said: Well, those braces can be expanded to as many lines of code as you would like. You could write it like this: Yes, but I wanted to have a automated method... no need to write Module::Sub_module.method, just copy a line that returns current method in the ruby console. @dan said: Why not just open the rb in an editor, and find the command in the file ? that's what I do when I search the command. But I am not sure a "non-ruby" user could find this command easily. @unknownuser said: BTW.. sometimes there is good reason for a command to be kept private, a commercial plugin, or a Pro only plugin. The writer of a plugin, has the right, to not allow their plugin (or it's tools,) to be called in ways that could defeat the license, or cause other problems. I am not saying this bit of code MUST be inserting in each plugin, of course... Just for MY personal plugins, because I like transparency.. I just asked this forum if someone had a better (or a native) way to do like my little method...
  • Set new value of Dynamic Component Attribute and recalculate

    3
    0 Szavazatok
    3 Hozzászólások
    591 Megtekintések
    TIGT
    You change [or add] the appropriate attribute[s] for the dynamic_component and then force it to refresh thus... assuming the dynamic_componentis referenced by 'dc' and you know the 'key'/'value' wanted... dc.definition.set_attribute("dynamic_attributes", 'key', 'value') $dc_observers.get_latest_class.redraw_with_undo(dc)
  • Raytest Alternative?

    7
    0 Szavazatok
    7 Hozzászólások
    754 Megtekintések
    A
    Well I hadn't thought of the sun vector that way, but that is great advice-- should certainly speed things up, a little at least. As for the number of faces...I'd like to take a surface and run it with arbitrary granularity; so, thousands. Running my code as it stands for 1000 faces takes on the order of 15 minutes to run. Making the change you suggested now...
  • Need help with structures in callbacks

    8
    0 Szavazatok
    8 Hozzászólások
    5k Megtekintések
    A
    @thomthom said: @dan rathbun said: And it's Windows only. We really need a solution that works on both platforms (Mac and Windows,) and that means it needs to be built into the Sketchup API by Google. That depends if he is aiming to support both platforms... Well, yes, I do want to support those for both platforms, but its just a starting test for platform that I'm using. And its not I'm the only one who want's that, I know there is much more people that would also want that ability in their plugins. So, yes after a solution to this topic, the code will be extended into more abilities of using on other platforms. @dan rathbun said: Including a library file (Win32,) in the global ObjectSpace is a big no no. Your code needs to be wrapped within a module. BIG Thanks Dan This thing was bugging me all the time I've need to wtite a code. This was a thing I needed to be sure of. @dan rathbun said: If you look at some of the pure Ruby source in Dan Berger's windows-pr package, you'll come across examples of accessing C structures from Ruby using Array.pack and String.unpack Thanks , think this is a solution. I no doubt, WILL examine the pakage!!!
  • Sketchup.parse_length

    12
    0 Szavazatok
    12 Hozzászólások
    760 Megtekintések
    fredo6F
    @adamb said: However, in your string_to_length(), I don't think SketchUp supports units of "km", "feet" and "mile" (though it will accept ' and " for foot and inch respectively) These functions are primarily geared at getting input from user (via VCB or dialog box). So, even if units are not supported by SU, the notation accepts it (like the dot and comma for the decimal separator). The functions also support the architectural notation with ' and " (though I am not fully familiar with it). For instance s = "2'3\" + 5' 8\"" --> 2'3" + 5' 8" Traductor.string_to_length_formula(s) --> 95.0 s = "3\" * 4" --> 3" * 4 Traductor.string_to_length_formula(s) --> 12.0 Traductor.string_to_length("1.0splishysplash") --> nil Fredo
  • Multiple line select

    4
    0 Szavazatok
    4 Hozzászólások
    396 Megtekintések
    Dan RathbunD
    There IS a work-in-progress on a BIM type plugin that can make walls, and export to IFC. Maybe you could join in with that project ?? [Plugin] bim-tools 0.9.0 (8 Oct 2011)
  • Transparency in Sketchup 6

    13
    0 Szavazatok
    13 Hozzászólások
    2k Megtekintések
    Dan RathbunD
    @john_q said: I'm new to sketchUp, using V8 and also new to the OOP-structure business... See: Ruby Newbie's Guide to Getting Started
  • Color components

    10
    0 Szavazatok
    10 Hozzászólások
    662 Megtekintések
    TIGT
    IDs do not subsist across sessions as they are re set every time the SKP opens. You must give entities attributes which will be carried across sessions to find them successfully...
  • Determining if a point is "in front" or "behind" a surface

    10
    0 Szavazatok
    10 Hozzászólások
    982 Megtekintések
    Dan RathbunD
    Yes Type validation would (as TIG showed,) is usually the norm for public libraries. If it's a private library and you are the only one calling it's methods, you will know the rules (arg types,) and such validation can be left out to speed things up. That said.. I put the nil test in as the API doc refers to "a plane if successful" but does not really say what the return value is, if the call is not successful. And as there is no "real" Plane class we cannot do a type check based on that, but if it's an array with 4 elements. Comment it out if you feel it's unnecessary. (I won't feel bad.)
  • Follow me code issue?

    12
    0 Szavazatok
    12 Hozzászólások
    2k Megtekintések
    Dan RathbunD
    Good "Occamish" advice TIG.

Advertisement