⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
  • Unzipping archive from Ruby (Mac and Windows)

    55
    0 Votes
    55 Posts
    10k Views
    tt_suT
    @eneroth3 said: What do you think is the best implementation? What about showing a web dialog or UI.messagebox when the plugin loads and the gem isn't installed telling the user that the gem is required? The user can choose to do it later (next time plugin is loaded) and the extension wont load or choose to download it now and there's a message saying it may take some time. The user would also be informed that this only has to be done once (per user and computer). Of course the extension warehouse info page would say that the extension will ask the user to install the gem and then automatically do it. There is no need for user interaction. You simply call Gem.install("nameOfGem") and it's done automatically for you. Look at the Gem module in the StdLib: http://ruby-doc.org/stdlib-2.0.0/libdoc/rubygems/rdoc/Gem.html However, you might want to call that only right before you need to use the gem - otherwise, if you call that in the head of the RB file with all the other require's it'll lock up SketchUp until the gem has been downloaded and installed. Not a big deal perhaps in the normal cases - but imagine if a user copied a few extensions that did this, then there's be a potential large lag during startup. But only once.
  • Help requested for checking all nested instances

    11
    0 Votes
    11 Posts
    1k Views
    sdmitchS
    @bobvandevoort said: Ah I'll try to be a bit more specific. Let's say I have a model with 3 components, comp1, comp2 and comp3. comp1 has comp2 inside and comp3 is inside of comp2. This then means (if I am correct) that comp1 has a transformation, called trans1, comp2 has one called trans2 and comp3 has one called trans3. If I take comp3 and place it in the model with its own transformation, trans3, it will not be places at its original position in the model. To achieve that it needs to have its transformation multiplied by trans2 and trans1. So now I want to create a matrix "noembed" that only has components that have no other components nested inside them (like comp3 here). However these components should still retain there original location/position in the model meaning their own transformation should be multiplied by all their parent's transformations. In which case this code seem to do the trick cd.instances.each{|ci| > next unless ci.parent==mod > trans_matrix << ci.transformation > noembed << ci > } You are correct that the transformation of comp3 not embedded will be the product of its' and the components instances transformations above it. The code above only would only save comp3's transformtion if it is at the model level. It would be great if you could start at the instance and work up to the top but .parent returns a component definition which doesn't have a transformation associated with it. So you have to start at the top and drill down. This code does that for two levels. Adds a comp3 at model level and erases the instance that it replaces. mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection rmv = [] ci0 = ent.grep(Sketchup;;ComponentInstance);#parent is mod ci0.each{|c0| next if c0.definition.name=="comp3" tr0 = c0.transformation ci1 = c0.definition.entities.grep(Sketchup;;ComponentInstance);#parent is definition ci1.each{|c1| tr1 = c1.transformation if c1.definition.name=="comp3" tr = tr0*tr1 ent.add_instance(c1.definition,tr) rmv << c1; break else ci2 = c1.definition.entities.grep(Sketchup;;ComponentInstance);#parent is definition ci2.each{|c2| tr2 =c2.transformation if c2.definition.name=="comp3" tr = tr0*tr1*tr2 ent.add_instance(c2.definition,tr) rmv << c2; break end } end } } rmv.each{|ci| ci.erase! if ci.valid?}
  • Running Sketchup as a service with sinatra

    9
    0 Votes
    9 Posts
    1k Views
    D
    SU used to modify set, since ruby 2 it dosen't john
  • Ruby api: reference point within a component

    3
    0 Votes
    3 Posts
    761 Views
    Dan RathbunD
    Yes you do not need to search among ALL the house's entities, IF you know the door's definition. IF you do, then simply look in the definition's instances() collection. If there are multiple door definition's, then you can iterate the model's DefinitionList collection, testing each definition for some identity (name value, or attribute in an attribute dictionary, etc.,) ignoring any definitions that have no instance, ie: !defn.instances.empty?
  • Material, Layer, Color, Alpha

    15
    0 Votes
    15 Posts
    1k Views
    M
    Dan, @dan rathbun said: Greg you have been "ignored" because you are a troll. You have a total of 23 posts here. I have near 5000! You are both incorrect and insignificant. As I stated, condescending. The fact that I choose to spend my free time away from computers doesn't really have any bearing on what I know or what I've said. I don't recall there being a relationship between quantity and quality regarding forum posts. Most forums always have a few people who feel their (often newfound) knowledge is so unique and authoritative that they post to almost every thread... Please enlighten me and post a link to anywhere on the Internet that says something similar to your statement 'there are no properties in Ruby.' Same thing goes for the statement 'Most methods return new objects.' By the way, you use the word 'new.' Since you've mixed it up before, are you referring to a new object like material.color, or a reference to a child object like Sketchup.active_model.entities? You've misused many programming terms that have relatively standard definitions, and, as I've stated previously, you conflate Ruby and the SU API. I'd suggest you do some reading and join some other programming forums/lists. BTW, my 'Design Patterns' book by the 'Gang of Four' is 2nd printing. I think it's currently at the 40th (or more) printing. Do you have a copy? Greg
  • Reading what is sent to the console?

    3
    0 Votes
    3 Posts
    380 Views
    jiminy-billy-bobJ
    Actually, since I posted I found another way to do what I want. But thanks for your answer, that's interesting. So I guess that's how the custom ruby consoles do it?
  • Layout linking in skp?

    4
    0 Votes
    4 Posts
    329 Views
    D
    cheers tig, I couldn't find one, but thought I was missing something... the best way I found so far is to open the .layout enclosed .skp set up the view you want in the .skp file use that as an icon for the .layout close without saving the .skp... It doesn't appear to break anything... any potential it might? john
  • Get point at 30 degrees

    3
    0 Votes
    3 Posts
    323 Views
    S
    The trig functions are available in the Ruby Math module, e.g. Math.tan(), and SketchUp's extended Numeric class knows how to convert between radians and degrees, so just rewrite your excel expression as SketchUp Ruby: side = Math.tan(30.degrees)*36.0 Note: SketchUp's radians and degrees functions name the source dimension and convert to the other, so 30.degrees means the value 30 is in degrees and you want radians. [sdmitch beat me to it!]
  • How to run Scrambler on windows 7 ?

    4
    0 Votes
    4 Posts
    459 Views
    G
    I have a number of scrambled files and a number of different projects. I put several batch files on the desktop and run them every time I make a change to any of the rb files. I put the files in a a public shared area so that I don't have to worry about virtual store with Windows 7 and so that I can place a single loader.rb file in many sketchup versions plugins folder. This allows me to work with 1 set of files for SU7, SU8, SU 2013, SU 2014 and SU 2015 replace project_1 with your own project and file_1.rb with your own file. My batch files have up to 40 lines - takes about 2 seconds to run on my old computer. c:\src\SketchUpRubyScramblerWindows.exe c:\src\project_1\file_1.rb c:\src\SketchUpRubyScramblerWindows.exe c:\src\project_1\file_2.rb xcopy "c:\src\project_1\file_1.rbs" "C:\Users\Public\Documents\Sketchup\project_1" /Y xcopy "c:\src\project_1\file_2.rbs" "C:\Users\Public\Documents\Sketchup\project_1" /Y xcopy "c:\src\InstallFiles\Sketchup\project_1*.png" "C:\Users\Public\Documents\Sketchup\project_1" /Y xcopy "c:\src\InstallFiles\Sketchup\project_1*.pdf" "C:\Users\Public\Documents\Sketchup\project_1" /Y xcopy "c:\src\InstallFiles\Sketchup\project_1\readme.txt" "C:\Users\Public\Documents\Sketchup\project_1" /Y
  • I need someone who can build a plugin.

    5
    0 Votes
    5 Posts
    434 Views
    sdmitchS
    If you could, post a model demonstrating the results the plugin is to achieve.
  • Ruby : Get dimensions of a transformed element

    5
    0 Votes
    5 Posts
    514 Views
    Dan RathbunD
    @nicoiweins said: OK it seems great and for a bounding box? use group_instance.bounds() which is inherited from Sketchup::Drawingelement, the superclass of Sketchup::Group (and most all model objects that are seen.) Even more model objects are descended from Sketchup::Entity, including Sketchup::Drawingelement. Each Ruby class inherits from it's ancestor classes.
  • Detect Linux from the RUBY or Sketchup API

    8
    0 Votes
    8 Posts
    948 Views
    tt_suT
    I would place my bets with Andreas - as he use Linux and probably have figured this out. Looking for a Wine related environment variable makes sense since Wine would make SketchUp think it's running Windows - RUBY_PLATFORM wouldn't say linux.
  • Alpha transparency in back face

    27
    0 Votes
    27 Posts
    4k Views
    S
    Tig, I checked, but AdamB is right ... @adamb said: @tig said: In code you can ensure a face's normal is towards the camera [get angles between the view direction and the face.normal], if >180 you are looking at the front ! TIG, strictly this is only true for a parallel projection. Its broadly correct for perspective projection, but not for all cases. The search for the "internal" and "external" of the object, this is the only way to evaluate the order of the vertices of the faces. Instead, this code seems to be a solution. It is a raw code ... it investigates only the skin of a compact object, devoid of undercuts ... but I will write the recursive routine. the ray must to come and to go in the solid, each IN must find his OUT in the space, and to end this way in the open space, switching the on - off ... otherwise the beam was started by a face looking at the inside of the object, and the normal of that face watch inside (what I have to correct) ... if face.material==nil #and face.back_material!=nil model = Sketchup.active_model vertx=mesh.polygon_at 1 ray = [mesh.point_at(1), face.normal] item = model.raytest(ray, false) if item.to_s.length!=0 then # UI.messagebox(item.to_s.length.to_s) face.reverse! # face.material=face.back_material # else # UI.messagebox("ok") end end PS: at this moment in the code the point is one random of the face vertexes, it would be better to define an interior point on the plane of the face, which is not disturbed by any adjacent faces at 90 degrees that can confuse
  • [Info] Allowable Classes for &quot;set_attribute&quot;

    57
    0 Votes
    57 Posts
    6k Views
    Dan RathbunD
    Storage: dict["keyname"]= ary.inspect Retrieval: ary = eval(dict["keyname"]) It has no problem with an empty array. There is something in the code of the set_attribute method, that will ignore even a string representation such as "[]" ?
  • Copy from Autocad to Sketchup

    14
    0 Votes
    14 Posts
    4k Views
    Dan RathbunD
    See Jim's list here. http://sketchucation.com/forums/viewtopic.php?t=34840#p374097 There are a few more perhaps added since then.
  • Style validation

    8
    0 Votes
    8 Posts
    458 Views
    CadFatherC
    ok TIG, thanks for that, i shall have a go with this. i thought i wasn't too far with my first example! Thanks!
  • WebDialog parameters passed to callback cause .to_l error

    29
    0 Votes
    29 Posts
    1k Views
    TIGT
    But that Ruby float as a string is ALWAYS going to return "1.0", so it always sets as "." even when the user's day-to-day decimal-separator is "," The issue is how the user input of "1,0" is correctly read as a float or a length. In the UI 'input' the default input type pretty much sorts that out. Since 1.0.m displays as 1.000m or 1,000m depending on the user's locale [and of course the model's unit settings] In a webdialog it's more awkward, because all input is a string that needs 'interpreting'. So the earlier posts' trickery using lengths etc to get the real separator would help... Certainly when initially populating the webdialog with decimal values... Like sep = (begin;'1.0'.to_l;'.';rescue;',';end) So if sep==',' we present decimal numbers differently using something like tr('.',',')? But surely some leeway could be used... What if a user first inputs x = 1.0 then x = 2,3 ? Should BOTH be acceptable ? So assuming they are expected as floats... if sep=='.' x.tr!(',','.') else #',' x.tr!('.',',') end For the display-side this makes either typed in separator suit the the 'locale', but on the Ruby-side, it's always x_float = x.tr(',','.').to_f For inputted 'lengths' it is different, because the Ruby-side expects it to be in the locale separator format... The first sep==...tr... still applies to ensure it's locale friendly... BUT then the x_length = x.to_l must be used Ruby-side...
  • Merging two or more faces

    8
    0 Votes
    8 Posts
    2k Views
    S
    @tt_su said: Grouping and exploding will be very slow. And add_group with existing entities has been prone to erros and crashes. But Mr.tt-su, when I use entities.intersect_with it doesn't work, can you explain why? After all I'm using grouping just once because my plugin I'm creating right now is dealing with just two faces, not like the sample I gave. [EDIT] I'v tried your plugin and it seems it works only for a ready intersected in the model faces, if I have two faces say from my sample face1 and face2, then your plugin can't work on them unless they are intersected in the model first, if you draw two simple intersected rectangles in sketchup and say selected them, then you plugin can work, hope you get my point. My problem till now is that I have two intersected faces but they are not intersected with the model and I want to merge them. one option gave by TIG to use entities.intersect_with method but failed with me, I don't know exactly the arguments of this function.
  • C SDK - how to export a model to a dwg file

    7
    0 Votes
    7 Posts
    565 Views
    tt_suT
    @gábor said: The downloadable SDK pack itself contains an XML exporter example. It is a good start to examine that. This is what I'd recommend as well. The C SDK is for reading and writing SKP files. If you need to convert to another file format you need the C SDK then convert to the target file format manually.
  • Is the C SDK upgraded to handle v2015 files?

    7
    0 Votes
    7 Posts
    520 Views
    G
    And it works flawless with v2015 files. Thanks again.

Advertisement