Urasik Extensions | Lots of new extensions to check out Learn More

Subcategories

  • No decscription available

    20 Topics
    462 Posts
    HornOxxH
    @pilou said: More appetizing in chocolate! Eggs are good as well - but only very fragile when falling down in SketchyPhysics
  • Dynamic components double action

    16
    0 Votes
    16 Posts
    1k Views
    G
    I have now coded the dynamic attributes into my plugin for bifold doors. There was a gotcha that I wasn't expecting. It took me a lot longer to understand what was going on. I started out just calling the script over and over to create up to 4 doors which handles a double bifold. Three problems, code was starting to get messy, execution was starting to take more time and memory and storage was increasing too much. So I now create 1 door create a second instance then flip it. Then take the bifold (2 doors) and instance it and flip them. This caused havoc. As soon as I tried (in code) to change the axes of the second door the door no longer behaved as expected. Turns out that Rotz on the flipped door changed from 0 to -180 and all I did was flip the door. Of course if you flip the door in the editor the rotz stays at 0. flip the sibling tr = Geom::Transformation.scaling(sibling.bounds.center, -1, 1, 1) sibling.transform!(tr) If I change axes after flipping door then the door moved to an unexpected place. If I change the axes before flipping the door the axes gets flipped as well causing the door to move over. The solution I came up with was to create a parent container to hold the door. Flip the door. Since the parent's rotz stays at 0 I could reference the grand parents angle. Creating another level of nested containers effectively insulates the animate coding from the effects of flipping the door.
  • How should i use s and t scale factor from SUTexture ?

    2
    0 Votes
    2 Posts
    387 Views
    tt_suT
    For the record, ongoing conversation at: http://forums.sketchup.com/t/how-should-i-use-s-and-t-scale-factor-from-sutexture/4589/6
  • Material observer behaviour on OS X

    4
    0 Votes
    4 Posts
    429 Views
    tt_suT
    @eneroth3 said: <offtopic> There's a Materials.current method ?? For my latest project I created a materials observer listening to active material change just so it could be assigned to a variable so I later could know what material is active. How could I have missed this? cleaning up some code </offtopic> Beware that the material might not be in the model yet - in older version of SketchUp it can cause crashes if you try to apply the material to entities.
  • Remove layer doesn't work?!

    5
    0 Votes
    5 Posts
    605 Views
    TIGT
    Jim is correct. If, via Ruby, you give a layer a color with transparency it is ignored and it renders opaque. Sp currently you can only change a layer's color through the API - there is no alpha OR texture support within the API, although of course you can do both of those manually...
  • Unzipping archive from Ruby (Mac and Windows)

    55
    0 Votes
    55 Posts
    11k 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
    2k 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
    812 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
    428 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
    396 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
    381 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
    533 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
    520 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
    603 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
    1k 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
    5k 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
    7k 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
    5k 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
    547 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!

Advertisement