ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Reading what is sent to the console?

    3
    0 Votes
    3 Posts
    308 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
    280 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
    284 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
    417 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
    361 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
    438 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
    878 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 "set_attribute"

    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
    367 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
    914 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
    468 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
    405 Views
    G
    And it works flawless with v2015 files. Thanks again.
  • Draw face from webdialog

    2
    0 Votes
    2 Posts
    276 Views
    sdmitchS
    add an action to the form <form action="skp:ruby_messagebox@"> change button type to "submit" In the callback tokens=params[1..-1].split("&"); tokens.each{|t| var,val = t.split("="); case var when "pt1" then pt1=Geom::Point3d.new(val) . . end
  • OnElementAdded inside Group or Component

    4
    0 Votes
    4 Posts
    489 Views
    M
    Hi, I've been experimenting on adding/removing EntitiesObservers when groups/components are opened/closed, and I've found difference in behavior in old and new Sketchup versions. When I have few nested groups and I open/close them multiple times (without leaving top parent group): Sketchup 8 and Sketchup 2013 - observers are added/removed as expected and each new entity is detected only once Sketchup 2014 and Sketchup 2015 - it seems like observers aren't removed each time 'onActivePathChanged' is called (although in console is printed that they are removed). When I add new face inside some nested group it is detected multiple times. Number of times EntitiesObserver is called is increased each time I open/close some subgroup. Below it the code which is independent from my plugin and can be simply loaded in Sketchup for testing purposes: module DL;;Daylighting #Attach observers to model, entities and materials class DLAppObserver < Sketchup;;AppObserver def initializeObservers(model) model_observer = DL;;Daylighting;;DLModelObserver.new() model_observer.initializeObservers(model) model.add_observer(model_observer) end def onNewModel(model) initializeObservers(model) end def onOpenModel(model) initializeObservers(model) end end class DLModelObserver < Sketchup;;ModelObserver @@observers = {} @@entitiesObserver = nil def initializeObservers(model) @@entitiesObserver = DL;;Daylighting;;DLEntitiesObserver.new() model.entities.add_observer(@@entitiesObserver) end #When new group is opened remove old observers and add new observer for active_entities def onActivePathChanged(model) puts "active path changed" #remove all previous observers @@observers.each_pair{|entities,observer| begin puts "***entities #{entities} remove observer #{observer}; #{entities.remove_observer(observer)}" rescue Exception => e puts "Can't remove observer",e.message end } @@observers={} #if all groups are closed -> don't add observers if !Sketchup.active_model.active_path return end entitiesObserver = DL;;Daylighting;;DLEntitiesObserver.new() entities = Sketchup.active_model.active_entities puts "***entities #{entities} add observer #{entitiesObserver}" if entities.add_observer(entitiesObserver) @@observers[entities] = entitiesObserver end end end class DLEntitiesObserver < Sketchup;;EntitiesObserver def onElementAdded( ents, new_ent ) #detect only Sketchup;;Face entities if new_ent.class == Sketchup;;Face puts "onElementAdded #{ents}; #{new_ent}" end end end end #DL;;Daylighting To attach these observers to the application just in call in Ruby console app_observer = DL;;Daylighting;;DLAppObserver.new() app_observer.initializeObservers(Sketchup.active_model) Sketchup.add_observer(app_observer) I don't understand what I'm doing wrong, because printed messages in ruby console show that old observer is always removed from entities when Active path is changed, but still new faces are detected multiple times. Once I leave all groups and go back to model (active_path=nil), all observers are like reset and I have only one EntitiesObserver. When I go inside groups and subgroups again, the number of observers increases again. And to repeat, in Sketchup 8 and Sketchup 2013 - this problem doesn't exist. Any suggestion is welcome, because I'm moving in circles with this observers. Thanks in advance, Marija
  • Selected Dim to Component Instance

    4
    0 Votes
    4 Posts
    342 Views
    K
    Thanks for the help. I'll try your suggestions. Keith
  • Cut and Paste-in-place from within Component Instances

    20
    0 Votes
    20 Posts
    1k Views
    JClementsJ
    Try this script which Sdmitch created. Edit a "top level" instance, make a selection (can be a group, a component, loose geometry or any combination of them), then run the script from the Edit menu > item "Cut selection within Comp Instance and Paste in Place from all Instances" (it is a long description, change if it if you want one less lengthy). You will be given an option to place the objects to be pasted onto a specific layer. I tested it in SU2014 and SU2014. Cut and Paste in Place.rb
  • Error in Triangles with a small side

    13
    0 Votes
    13 Posts
    836 Views
    S
    @driven said: are you updating su2pov3.rb or starting again? john No, it's an old version, I'm working on a new one, but unfortunately I'm trying to understand how to use SketchUp Alpha declared a value on one side, and a different value in the same back_face simultaneously. All this is complicated by the same concept in the statements of the parent block. A problem that for now I can not find answer ..... This is a version a bit less old, but I hope to improve soon http://imitidicthulhu2.blogspot.it/2010/12/skup2ray-v006.html

Advertisement