ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • SketchUp 8 and Volume Attribute

    4
    0 Votes
    4 Posts
    592 Views
    thomthomT
    @tig said: See this http://code.google.com/apis/sketchup/docs/ourdoc/componentinstance.html#volume It returned for the Instance as it currently is - like the face.area method... He's trying to read data from .skp files on disk - not within SU Ruby API.
  • [Test] defn.count_instances vs defn.instances.lenght

    3
    0 Votes
    3 Posts
    253 Views
    thomthomT
    Duh! Should off course have eliminated new object creations. (They are all too expensive.) Changing it and the numbers are quite different: d=Sketchup.active_model.definitions[0]; inst=d.instances; c=10000000; puts "Counting #{d.count_instances} instances..."; t=Time.now; c.times { d.count_instances }; puts "Count: #{Time.now-t}s"; t=Time.now; c.times { inst.length }; puts "Count: #{Time.now-t}s" Counting 8642 instances... Count: 3.562s Count: 1.795s
  • "Grayed out" Menu items

    3
    0 Votes
    3 Posts
    220 Views
    honoluludesktopH
    Thanks Tom, I really did try to find it.
  • Sketchup 8, serious observer bug?

    19
    0 Votes
    19 Posts
    1k Views
    M
    Well, I'm happy to test it out, on SU7 & 8 Pro. But programming? Nope. But with TIG and ThomThom commenting here you've already got some deep SU Ruby knowledge. If we can ask them to get involved .... As suggested, there's nice exporters for POVray and Kerkythea, which means we may be able to draw on others in the forums too. Supporting another good OSF renderer in SU would be helpful to all involved. What functions do you think needs to be done to move this project along, and then to the next level?
  • Ruby Scrambler Download

    10
    0 Votes
    10 Posts
    5k Views
    Dan RathbunD
    rav11, clarify.. (please) do the Mac scrambled scripts work on SU ver 7.x ?? and not work on SU ver 8.x ??
  • SKM tools

    4
    0 Votes
    4 Posts
    1k Views
    TIGT
    There's an updated 'extra' Material.save_bumpmap(folder, inverted) tool added. http://forums.sketchucation.com/viewtopic.php?p=291646#p291646 It's been sent to 'beta-testers' - are there any others interested in trying it out 'cross-platform'?
  • Film and Stage plugin - need help to fix script

    29
    0 Votes
    29 Posts
    2k Views
    D
    @Tig and Chris, I had a play using view.vpwidth and .vpheight but don't understand why it doesn't work, I ran this code on the same drawing with and without a 'Camera' view and thought it might show you if Mac's handle things differently, or not. I thought using the second set of co-ords to output a file would work, but I'm doing something wrong so I'll leave that off this post. [code] > view = Sketchup.active_model.active_view # Determine the size of the design window h = view.vpheight.to_s w = view.vpwidth.to_s puts "Window dimensions; " + w + ", " + h # Display the locations of the four corners puts "Upper left; " + view.corner(0)[0].to_s + ", " + view.corner(0)[1].to_s puts "Upper right; " + view.corner(1)[0].to_s + ", " + view.corner(1)[1].to_s puts "Bottom left; " + view.corner(2)[0].to_s + ", " + view.corner(2)[1].to_s puts "Bottom right; " + view.corner(3)[0].to_s + ", " + view.corner(3)[1].to_s # Show the location of the window's center center = view.center puts "Center; " + center[0].to_s + ", " + center[1].to_s # Screen coordinates origin = view.screen_coords [0,0,0] puts "Origin; " + origin[0].to_f.to_s + ", " + origin[1].to_f.to_s Window dimensions; 1924, 1089 Upper left; 0, 0 Upper right; 1924, 0 Bottom left; 0, 1089 Bottom right; 1924, 1089 Center; 962, 544 Origin; 579.166591415118, 705.802307848725 nil > view = Sketchup.active_model.active_view # Determine the size of the design window h = view.vpheight.to_s w = view.vpwidth.to_s puts "Window dimensions; " + w + ", " + h # Display the locations of the four corners puts "Upper left; " + view.corner(0)[0].to_s + ", " + view.corner(0)[1].to_s puts "Upper right; " + view.corner(1)[0].to_s + ", " + view.corner(1)[1].to_s puts "Bottom left; " + view.corner(2)[0].to_s + ", " + view.corner(2)[1].to_s puts "Bottom right; " + view.corner(3)[0].to_s + ", " + view.corner(3)[1].to_s # Show the location of the window's center center = view.center puts "Center; " + center[0].to_s + ", " + center[1].to_s # Screen coordinates origin = view.screen_coords [0,0,0] puts "Origin; " + origin[0].to_f.to_s + ", " + origin[1].to_f.to_s Window dimensions; 1924, 1089 Upper left; 0, 135 Upper right; 1924, 135 Bottom left; 0, 954 Bottom right; 1924, 954 Center; 962, 544 Origin; 285.625823583734, 829.482222498574 nil [/code]
  • View.draw_lines point1, point2

    3
    0 Votes
    3 Posts
    239 Views
    honoluludesktopH
    Tig, thanks.
  • Edit the dxf/dwg importer

    3
    0 Votes
    3 Posts
    242 Views
    TIGT
    @pout said: Simple question: Is the dwg/dxf importer accessible? Thx You use Sketchup.active_model.import(path_to_CAD_file.dwg, boolean) The importer knows from the file suffix if it's a dwg or dxf. The boolean controls if a report is displayed - true/false... You can't readily control the 'options' as the ones currently set in the manual Import options for dwg/dxf will be used for the API import... [You can 'script' PC code to open the import dialog and change options but it's a bit clunky - see an old version of my 'Xref Manager' script set...]
  • Plugin running indefinitely

    10
    0 Votes
    10 Posts
    529 Views
    T
    Thanks for all of the help, im now using a timer which solves the problem perfectly
  • Creating an avi file with a plugin

    13
    0 Votes
    13 Posts
    717 Views
    P
    hmm tried mencoder a lot of times and it is not that easy to get ruby running the mencoder line in a command window (things with locatiosn of the imgages and the mencoder exe come back to mind) ffmpeg is easier
  • Sketchup Animation Path Shape

    6
    0 Votes
    6 Posts
    974 Views
    D
    @chris fullmer said: How does VUE set up its animations? With "keyframes" between camera locations, and then you apply a linear or bezeir transition? I do not know if you will be able to accurately recreate the camera path that SketchUp uses. But you could export the camera location at each frame, effectively makeing each frame a key frame with a linear transition betwen them. The ruby API allows you to get the camera object for each frame of its animation. So I would guess that the best way to do what you're looking for is to have the user input the desired frame rate inside of SU, then export the camera location per frame to VUE and have VUE then set up the camera path frame by frame. Chris Thanks Chris. You confirmed what I thought. In Vue, you can create linear or curved animation paths. It appears that Sketchup uses some sort of arc-like movement when the camera is rotated around the scene. I like your idea of capturing intermediate key frames - I'll give this a try.
  • Need help on writing threaded plugin code

    10
    0 Votes
    10 Posts
    895 Views
    RichMorinR
    @thomthom said: UI.timer ? or a Javascript timer? This has to be a UI.timer, because it runs in the plugin (telling the plugin when to look for proxied messages from the JavaScript client code). I'm using SU 8, so the bug you mention isn't a problem for me. However, it would be nice to have a solution that works for earlier versions.
  • PBI - emulate WebDialogs in a browser?

    6
    0 Votes
    6 Posts
    935 Views
    RichMorinR
    @morgan_greywolf said: Sure, I'll take a look at it. I'm running SU8 on Linux/Wine. Great. You can get started with the proxy server and the test page; send me a note off-list (rdm@cfcl.com) letting me know what you find out. As soon as I have my example plugin ready for Alpha testing, I'll let you know. FYI, the plugin no longer sits in a read loop. Instead, I use UI.start_timer to perform periodic scans of the input directory. This seems to work quite nicely, but it does require SU8, because it's using a sub-second interval. Also, I'm still hoping for a CygWin and/or native Windows tester!
  • Inputbox prompts by variable

    3
    0 Votes
    3 Posts
    247 Views
    J
    In the first example, prompts is an Array of Strings, which is the correct form. In the second, p just a String; so when you write prompts = [p], y0u get an Array containing a single String. p = [] p << "What is your Name?" << "What is your Age?" << "Gender" prompts = p Do not use p as a variable. Although it does work, p is a shortcut for the .inspect method. p prompts is the same as puts prompts.inspect
  • Making an objects parallel to a line. (lookat function)

    5
    0 Votes
    5 Posts
    282 Views
    Chris FullmerC
    Then I too think it already exists. Check out Honolulu's script.
  • Testing user input as valid geo-location

    7
    0 Votes
    7 Posts
    294 Views
    honoluludesktopH
    Done, Thanks Dan. Haven't gotten back to working on this part of the code yet.
  • [Help!] creat a face from edges on existing face

    13
    0 Votes
    13 Posts
    720 Views
    K
    @heven7_floor said: I just learning ruby code in SU, and found problem about draw a face onto existing face, I can identify any method in new face further , such as <span class="syntaxdefault"><br /></span><span class="syntaxkeyword">@</span><span class="syntaxdefault">cir_face </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_face edges                     </span><span class="syntaxkeyword">----------></span><span class="syntaxdefault"> drawing it on existing face<br /><br />if not</span><span class="syntaxkeyword">(@</span><span class="syntaxdefault">cir_face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">normal</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">samedirection</span><span class="syntaxkeyword">?</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">dir_vec</span><span class="syntaxkeyword">)</span><span class="syntaxdefault">        </span><span class="syntaxkeyword">---------></span><span class="syntaxdefault"> get error </span><span class="syntaxstring">"undefine method 'normal' on nil "</span><span class="syntaxdefault"> <br />  puts </span><span class="syntaxstring">"change to initial direction"<br /></span><span class="syntaxdefault">  </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">cir_face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">reverse</span><span class="syntaxkeyword">!<br /></span><span class="syntaxdefault">end<br /></span> any one please help me to explain why cause of this error , I don't understand why I can't undentify this method thanks everyone in advance I've run into this problem before. Sketchup won't let you make a internal face with the add_face method. For example, if you simply draw a rectangle inside the interior of a face. Delete the rectangle's face. Select the 4 edges. The following code using Jim Foltz's Ruby Web Console won't remake the face: model = Sketchup.active_model ent = model.entities sel = model.selection edges = sel.to_a ent.add_face edges You need to use the "find_faces" method, but that only returns the number of faces made. So you have to go through the trouble of finding the face it made. So rewriting your code, it would work this way: #@cir_face = entities.add_face edges edges[0].find_faces faces = edges[0].faces for i in (0..faces.length) result = faces[i].classify_point(@f_point) if result == Sketchup;;Face;;PointInside @cir_face = faces[i] break end end I found this plugin very interesting. Here are some extra stuff, I cleared up at the beginning. The "normal=@inputpoints[0].normal" was giving an error, like everyone pointed out. Looks like to me, its the same vector as "@dir_vec". So I set it equal to that vector: #normal=@inputpoints[0].normal @dir_vec = find_vec(@inputpoints[0],@inputpoints[1]) normal = @dir_vec v_axes = @dir_vec.axes And I found that your pushpull direction only went positive and not negative. So added these extra lines before your pushpull: @pushpull_dir_vec = (@cpt_l-@f_point) if !(@pushpull_dir_vec.samedirection? @dir_vec) @cy_dist = -@cy_dist end status = @cir_face.pushpull @cy_dist,true Here is the modified file: circle_any_plan_&Pull(modified).rb
  • &quot; copy &quot; in component name

    4
    0 Votes
    4 Posts
    359 Views
    Al HartA
    @jim said: Dynamic Components have a Copies behavior that, when set to > 0 adds another Component and appends "copy ###". Thanks for the reminder. That was it. [image: asn9_spacecopy1.jpg] Needs to become: [image: KDBC_spacecopy2.jpg] Its too bad they didn't use something more unique than ' copy ', so it wouldn't look the same as a component with 'copy' already in the name.
  • Draw2d GL_POLYGON

    7
    0 Votes
    7 Posts
    913 Views
    J
    @thomthom said: Oh... so convex shapes will all be drawn like that? That's a bit of a bugger... In fact. But good news, I applied my good still in ruby (started to program in ruby last friday) to translate an algorithm that fix just that which we call polygon triangulation. I converted the algorithm from c++ to ruby: (Original source code: http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml) # @param contour is an array of Vector2d # @return area def triangulateArea(contour) n = contour.length a = 0 p = n - 1 for q in 0...n do c1 = contour[p] c2 = contour[q] a = a + c1.x * c2.y - c2.x * c1.y p = q end return a / 2 end # Check is P is inside the triangle formed by A-B-C. # @param A Point3d of the triangle # @param B Point3d of the triangle # @param C Point3d of the triangle # @param P Point3d that have to be checked if inside A-B-C # @return true if inside. def triangulateInsideTriangle(ax, ay, bx, by, cx, cy, px, py) i_ax = cx - bx i_ay = cy - by i_bx = ax - cx i_by = ay - cy i_cx = bx - ax i_cy = by - ay apx = px - ax apy = py - ay bpx = px - bx bpy = py - by cpx = px - cx cpy = py - cy aCROSSbp = i_ax*bpy - i_ay*bpx cCROSSap = i_cx*apy - i_cy*apx bCROSScp = i_bx*cpy - i_by*cpx return aCROSSbp >= 0 && bCROSScp >= 0 && cCROSSap >= 0 end # param contour is an array of Point3d where z is not used. # param u is an index in tV # param v is an index in tV # param w is an index in tV # param n is the size of tV # param tV is an array in index in contour. def triangulateSnip(contour, u, v, w, n, tV) ax = contour[tV[u]].x ay = contour[tV[u]].y bx = contour[tV[v]].x by = contour[tV[v]].y cx = contour[tV[w]].x cy = contour[tV[w]].y if 0.0000000001 > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) return false end for p in 0...n do if p != u && p != v && p != w px = contour[tV[p]].x py = contour[tV[p]].y if triangulateInsideTriangle(ax,ay,bx,by,cx,cy,px,py) return false end end end return true end # @param contour is an array of Point3d for a polygon # @return an array of Point3d where all 3 points is a triangle which # can be drawn with "view.draw2d GL_POLYGON, result" def triangulateProcess(contour) result = Array.new n = contour.length if n < 3 puts "Error; contour.length < 3" return nil end # We want a counter-clockwise polygon in tV tV = Array.new if triangulateArea(contour) > 0 for v in 0...n do tV << v end else for v in 0...n do tV << ((n - 1) - v) end end nv = n # Remove nv-2 Vertices, creating 1 triangle every time count = 2 * nv # Error detection m = 0 v = nv - 1 while nv > 2 # if we loop, it is probably a non-simple polygon if count <= 0 # Triangulate; ERROR - probable bad polygon! puts "ERROR - probable bad polygon! ???" return nil end count -= 1 # three consecutive vertices in current polygon, <u,v,w> u = v if u >= nv u = 0 # previous end v = u + 1 if v >= nv v = 0 # new v end w = v + 1 if w >= nv w = 0 # next end if triangulateSnip(contour,u,v,w,nv,tV) # true names of the vertices a = tV[u] b = tV[v] c = tV[w] # output Triangle result << contour[a] result << contour[b] result << contour[c] m += 1 # remove v from remaining polygon s = v t = v + 1 while t < nv tV[s] = tV[t] s += 1 t += 1 end nv -= 1 # resest error detection counter count = 2 * nv end end return result end How to use: You have to call triangulateProcess with an array of point that compose the polygon. It will return an array of point. But, this array is formed in a way that every 3 points create a triangle and can be used directly by view.draw2d GL_TRIANGLES. Ex: array = [[0,20,0],[20,0,0],[30,30,0],[20,20,0]] r = triangulateProcess(array) if !r.nil? view.draw2d GL_TRIANGLES, r end I hope it will be help some of you, Sincerely, Jo EDIT: Fixed errors in the code.

Advertisement