ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • SkethchUp write_image method

    2
    0 Votes
    2 Posts
    188 Views
    Dan RathbunD
    Too many variables. How would you for instance determine a harddrive's interface speed, and whether the write cache is on? If you want worstcase, then you could use old PATA speed of 33Mb/s, but most newer computers will have PATA of 100Mb/s. If the computer is late model, and has a SATA drive, the speeds can be up in the 3 .. 6 Gb/s range. So.. the easiest way would be to have the user fill in a WebDialog form for this info. They you would multiply width x height in pixels, by say 24bits each to get a approximate size for the image (if a BMP,) then divide by the interface speed. Estimating compressed format sizes (like GIF and JPEG,) will be much harder, but you might be able find some equations out on the web. (Then of course, there is extra processing time for the image to be compressed.) Sketchup uses PaintLib, an Open Source library. Perhaps there are some speed data on the PaintLib author's website?
  • Ptex??

    19
    0 Votes
    19 Posts
    1k Views
    soloS
    I know there are numerous 3rd party apps that can achieve the UV solutions SU lacks, however I really like the Ptex system. I guess I'm hoping for a SU solution still, without needing to add more apps to my workflow, export, import, just a simple, easy solution.
  • Interprocess communication

    3
    0 Votes
    3 Posts
    246 Views
    P
    Thanks, Dan. Your advice was very useful. I could have lost a lot of time on the other schemes which I referred to. The 'Programming Ruby' book by David Thomas and Andrew Hunt looks interesting. Downloaded the .so extension modules, installed them and run a Ruby console session: >require 'win32ole' true >ppt = WIN32OLE.new("PowerPoint.Application") #<WIN32OLE;0x11396c58> >ppt.Activate nil That's it: PowerPoint was activated, so I'm ready to use PPT automation in a SU script as desired. Really elegant. This scheme depends on the WIN32OLE extension written by Masaki Suketa. Can anybody give me advice on standard procedures for installation of such extensions on the machines of SU users. My post had another aspect: We are now capable of using Ruby as a client for Windows Automation. What about the other direction. Can SU be extended to become an automation server?
  • Select Visible geometry

    5
    0 Votes
    5 Posts
    651 Views
    honoluludesktopH
    If locating the faces is sufficient, you can start with my code here. Just noticed that there is a link to Chris's post too.
  • Coming Soon: Scene Groups!

    32
    0 Votes
    32 Posts
    5k Views
    S
    [image: hippo_bump.jpg]
  • Access Opacity

    3
    0 Votes
    3 Posts
    157 Views
    D
    Thanks - works perfectly.
  • Notepad++ and SketchUp Bridge in SU8

    8
    0 Votes
    8 Posts
    2k Views
    H
    @dan rathbun said: I actually have the bridge files installed in a common dir: %(#000000)[C:\Program Files\Google\TBD\SU_Bridge] .. and then I put a bridge_ext.rb file in each Plugin dir of the SU versions, that loads the files from the common dir. That way SUB.EXE is always in the same place, and you do not need to change the path to it within Notepad++ regardless of whatever version of Sketchup is loaded. [attachment=0:1pazsmqa]<!-- ia0 -->bridge_ext.rb<!-- ia0 -->[/attachment:1pazsmqa] This is excellent way, and it 's greatness solution ,thanks for your kindly help
  • Select entities in view

    3
    0 Votes
    3 Posts
    191 Views
    L
    Thank you for your suggestion. I have however in increasing desperation and frustration found a solution that seems to work. Downloaded a trial version of Deep Exploration, a notorious 3d conversion program. To my great surprise it does the job very fast! Opening my very complex model takes about 3 minutes, but then exporting a pdf or ai files takes about 30 seconds. And judging from what I have seen so far, the output is flawless. Literally tens of thousands of lines are outputted almost instantly. I am happy! So this is just an advice for other users with the same demands I have. Deep Exploration seems to be able to do it.
  • View.invalidate vs view.refresh

    12
    0 Votes
    12 Posts
    2k Views
    thomthomT
    @unknownuser said: @unknownuser said: Right - so if I make a wrapper that will refresh after a given max interval - otherwise invalidate - that would be an ok method? by using that you dont address the problem because you dont take in account system draw. but it can be used as workaround. So skip the view.invalidate all together?
  • UDP Socket and Threading in API

    3
    0 Votes
    3 Posts
    973 Views
    M
    As Dan pointed out UI.start_timer works pretty good with UDP. Here's how I'd write it: require 'socket' serverSocket = UDPSocket.new serverSocket.bind("127.0.0.1", 3157) timer_id = UI.start_timer(0.1, true) { begin data = socket.recvfrom_nonblock(100) new_message = true rescue Errno;;EWOULDBLOCK new_message = false rescue Errno;;ECONNRESET new_message = false UI.stop_timer @timer_id break end if new_message == true UI.messagebox(data) end } The major different is the UI.start_timer in place of the "Thread" and "Loop" in your example. You'll also see that it uses .recvfrom_nonblock with some error catching instead of just .recvfrom. This is because sketchup will hang if nothing is sent to the socket. If you're sure that there will be a constant stream of data you might be able to get it to work with blocking.
  • Ruby API Bugtracker?

    10
    0 Votes
    10 Posts
    991 Views
    tbdT
    of course this forum
  • Trying to retrieve face using ComponentInstance.glued_to

    5
    0 Votes
    5 Posts
    191 Views
    Dan RathbunD
    @lothcat said: @dan rathbun said: FYI: There is a missing ) in line 5 of the snippet. D'oh! Thank you! I was so sure I was using this wrong that I didn't even look for actual coding errors. Usually the Ruby error tells you what line of the code that the error is in, and echos that erroneous line. Also it may print an extra line beneath the erroneous line with a caret symbol pointing at where it thinks the error is. Not always helpful, as it may just point at the end of the code line if the parser doesn't really know, for instance, where the missing ")" symbol should go. And.. a syntax error IS a coding error, most often missing delimiters, brackets, etc.
  • How to store an Entity between sessions?

    8
    0 Votes
    8 Posts
    213 Views
    D
    Thanks TIG
  • Ruby plugin?

    16
    0 Votes
    16 Posts
    835 Views
    TIGT
    Thomas You really need to learn to crawl before you walk... You expect 'random lines of code' to be interpreted for you ! Please structure your questions a little more friendly... width, height = results presumably this follows a UI.inputbox that results= ? There were two answers... width & height ?? pts = tl[0].vertices sets an array called 'pts' to be the vertices related to the first element in the array tl - as it's not named logically that couls be a list of faces OR edges... i = 0 sets a reference called 'i' to be 0 [this is used later in the '.each do' loop ??? pts2 = [] Makes an empty array called 'pts2' - presumably this will be filled with elements later... pts.each do |pt| pts2[i] = pt.position + [0 , 0 , results[1]] i = i +1 end This process the vertices in 'pts' [it would've been better to call it 'verts' ??] And for each vertex [pt !!!] it returns its position as a 3d-point BUT swaps its z-value for whatever the results[1] was = probably the 'height' so why wasn't 'height' used ?? line_copy = entities.add_line pts2 Tis makes a line in [whatever] 'entities' [is] using the array 'pts2' as the 2 points - these have had their z values set to 'height'... pts_copy = line_copy.vertices This sets the array 'pts_copy' to be the vertices used by the edge 'line_copy' ??? i = 0 j = 0 sets the references 'i' and 'j' to 0 new_face = entities.add_face(pts[0], pts_copy[0], pts_copy[1], pts[1]) This sets the reference 'new_face' to be the face [if any] that is made using the 4 points listed [if they are not coplanar it will fail!] new_face.pushpull (width / 2) It pushpulls the 'new_face' by half of the 'width [i.e. results[0] set earlier] Do NOT leave a gap between the 'pushpull' and its argument in parentheses [i.e face.pushpull(xxx) NEVER face.pushpull (xxx)] model.commit_operation end This closes the 'operation' and 'end's something - presumably the ' def zid' ? You must have a model.start_operation("MyTool") to 'close' it later... [ruby:1dtqmkst]if( not file_loaded?("zid.rb") ) UI.menu("Plugins").add_item("Zid") { zid } end file_loaded("zid.rb")[/ruby:1dtqmkst] This makes the Plugins menu item a called '[ruby:1dtqmkst]Zid[/ruby:1dtqmkst]' which in turn runs the [ruby:1dtqmkst]def[/ruby:1dtqmkst] called '[ruby:1dtqmkst]zid[/ruby:1dtqmkst]' ??? The [ruby:1dtqmkst]file_loaded[/ruby:1dtqmkst] parts need you to have a [ruby:1dtqmkst]require 'sketchup.rb'[/ruby:1dtqmkst] earlier and ensure that only one menu item appears even if you manually reload the script into the same SKP session...
  • Makes a stair with component steps

    2
    0 Votes
    2 Posts
    195 Views
    sdmitchS
    Is this what you wanted revised stairsfms2.rb
  • Create a new line

    3
    0 Votes
    3 Posts
    173 Views
    TIGT
    You're making it too complex... pt0=[0,0,0] pt1=[1,0,0] Sketchup.active_model.active_entities.add_line(pt0,pt1) Adds a new line from the origin 1" long, to the right [i.e. X/red axis] The entities.add_... methods are listed in the API guides and cover many aspects of adding lines, arcs, circles, polygons, clines, cpoints, faces, text etc... please read them and have a mess around...
  • Open SKP in VB.NET Application

    9
    0 Votes
    9 Posts
    2k Views
    Dan RathbunD
    If you look in the SDK folder (where "SDK" is whatever name you gave it,): SDK\SkpWriter\Headers\source\sketchup\skpwriter\sapi and the specific file: applicationfactory.h you will see the following source line that declares an exported DLL function: %(#4040BF)[extern _declspec(dllexport) IApplication* GetApplication();] I believe you must first get a handle to the Sketchup Application Interface, by calling %(#4040BF)[GetApplication()]... then you can call that object's methods, such as getting the handle on the current document, or creating a new document (meaning a SKP model file.) All of the API classes and methods are listed in the "documentation" folders, but be sure to reference both of them. (There is a "documentation" folder under both the "SKPWriter" and "SKPReader" folders.) The files are html, and can be opened locally with your browser. (Click the "index.html" file to start off.) There are a few simple examples in the help docs for SKPReader. There are also a couple of VS project examples under the "Examples" folders.
  • AutoHotKey shortcuts for the Ruby Console

    7
    0 Votes
    7 Posts
    2k Views
    thomthomT
    @kwalkerman said: Hi Jim, This looks awesome. Sorry for the newbie question, but I can't figure out how to activate it. Where do I put the file? How do I start it from the ruby console? Thanks so much, -- Karen This is not a SketchUp Ruby, but an AutoHotKey file - follow the link in the OP.
  • Tracking changes of component definitions with observers

    9
    0 Votes
    9 Posts
    383 Views
    Dan RathbunD
    @adamb said: you may want this as a singleton that is shared amongst all instances (as you've almost written by mistake). Like so: # class definition inside module AC3D_Raven_Exporter class DefinitionsObserver < Sketchup;;DefinitionsObserver @@entities_observer = nil # ref to the singleton instance attr_reader( ;entities_observer ) def initialize() if @@entities_observer.nil? # ref'ing the class ref @@entities_observer = AC3D_Raven_Exporter;;EntitiesObserver.new() # otherwise the instance to the observer is valid and just reuse it. end @entities_observer = @@entities_observer end def onComponentAdded(definitions, definition) definition.entities.add_observer(@entities_observer) end end ADD: and you can do the same thing 1 level up (in your custom AppOserver,) by creating a singleton instance of the DefinitionsObserver, and attaching it to all the component definitions that you wish to "watch". I usually also write a detach_from() method, that uses an array or hash of "watched" items, in order to detach observers when I no longer need to watch them.
  • Resize DC with ruby

    6
    0 Votes
    6 Posts
    441 Views
    M
    Hello, I wrote a small code to add a DC at a specific position and resize it. So when Sketchup add an instance of a DC its position is 0,0,0. You need to define a transformation to place it where you want. t1 = Geom;;Transformation.axes(...,...,...) newDC = Sketchup.active_model.entities.add_instance(Sketchup.active_model.definitions["MyDC"],t1) To set the length I used the set_attribute method of the DC definition len = 13 len2 = 12 newDC.definition.set_attribute "dynamic_attributes","_lenx_nominal",len.to_s newDC.definition.set_attribute "dynamic_attributes","_lenz_nominal",len2.to_s

Advertisement