đź«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
  • Notepad++ Ruby Syntax enhancement

    10
    0 Votes
    10 Posts
    3k Views
    M
    @thomthom said: Can a Python lexer work with NP++? I've no idea. Took a look. My lexer is a Decaf lexer, written in Python. Decaf (Java without the Jitters) is a beginners language I've designed and am working on, but not often enough. Decaf is quite like Python in most things, except suites. I actually have decided to implement suites: if condition no braces around this block of code # no braces, no begin/end Fortunately for your requirement, Decaf's lexer still looks for {} around statement blocks. Unfortunately, Ruby persuaded me to add trailing IF and UNLESS but they're not there yet, either. I could add those soon. Here's the language description. Before you go here, "lexical analysis" and "lexing" are Decaf-described as "breaking the language into WORDS" (not tokens). Parsing is picking out PHRASES (not expressions) and SENTENCES (aka statements). The code and doc is in various stages of being converted to Decaf-speak. # Decaf's EBNF grammar # grammar of the grammar; # 'x' the character 'x' # 'xxx' the character string 'xxx' (as a separate word) # x | y either x or y # [ x ] 0 or 1 x # x* 0 or more x # x+ 1 or more x # {} grouping, example; # "exp{',' exp}+" - "exp" followed by one or more "',' exp" # < xx > comment (documentation of the grammar) # full_name, nm ;;= # x 'full_name' is defined as 'x', 'nm' is short for 'full_name' # # xxx; definition continued, next line # # name ;;= # x # y 'name' is defined as 'x | y' # # xxx_operator, xx ;;= # < operators of type 'xxx' listed here > #---------------------- words ----------------------- constant_e, con_e ;;= 'E' = 2.71828182845904523536 constant_pi, con_pi ;;= 'PI' = 3.14159265358979323846 comment_eol_word, cmt_w ;;= COMMENT_EOL end_of_line_word, eol_w ;;= END_OF_LINE end_of_input_word, eoi_w ;;= END_OF_INPUT end_of_statement_word, eos_w ;;= END_OF_STATEMENT line_continuation_word, lcon_w ;;= LINE_CONTINUATION whitespace_word, white_w ;;= WHITESPACE constant_integer_word, con_i_w ;;= CONSTANT_INTEGER constant_decimal_word, con_d_w ;;= CONSTANT_DECIMAL lbrace_word, lbrace_w ;;= LBRACE lbracket_word, lbrkt_w ;;= LBRACKET lparen_word, lprn_w ;;= LPAREN malformed_number_word, m_num_w ;;= MALFORMED_NUMBER multiline_string_word, ml_str_w ;;= MULTILINE_STRING name_word, name_w ;;= NAME operator_word, op_w ;;= OPERATOR rbrace_word, rbrace_w ;;= RBRACE rbracket_word, rbrkt_w ;;= RBRACKET reserved_word_word, res_wrd_w ;;= RESERVED_WORD rparen_word, rprn_w ;;= RPAREN string_word, str_w ;;= STRING unclosed_multiline_string_word, unc_mls_w ;;= UNCLOSED_MULTILINE_STRING unclosed_string_word, unc_str_w ;;= UNCLOSED_STRING unknown_character_word, unk_chr_w ;;= UNKNOWN_CHARACTER #------------------- expressions -------------------- arithmetic_operator, arth_op_p ;;= '+' | '-' | '*' | '/' | '^' | '%' copula_operator, cop_op_p ;;= '=>' comparison_operator, cmp_op_p ;;= 'GT' | 'GE' | 'EQ' | 'LE' | 'LT' | 'NE' | 'IN' binary_logical_operator, log_op_p ;;= 'AND' | 'OR' unary_logical_operator, not_op_p ;;= 'NOT' other_operator, oth_op_p ;;= '.' | ',' | ';' expression, expr ;;= arithmetic_expression comparison_expression logical_expression parenthesized_expression list_expression range_expression subscript_expression function_call selection_expression arithmetic_expression, arth_exp ;;= operand arithmetic_operator operand '-' operand comparison_expression, cmp_exp ;;= operand comparison_operator operand logical_expression, log_exp ;;= operand binary_logical_operator operand unary_logical_operator operand 'TRUE' | 'FALSE' comparison_expression parenthesized_expression, paren_exp ;;= '(' expression ')' list_expression, lst_exp ;;= expression {',' expression}+ range_expression, rng_exp ;;= operand ';' [operand] ';' operand < operands must be integers > subscript_expression, sub_exp ;;= '[' range_expression{',' range_expression}* ']' function_call, func_exp ;;= parenthesized_expression function_name function_name, func_nm ;;= NAME < name of defined or imported function > selection_expression, sel_exp ;;= NAME{'.' NAME}+ operand, oprand ;;= NAME constant expression constant, cnstnt ;;= CONSTANT_INTEGER | CONSTANT_DECIMAL | STRING | MULTILINE_STRING #-------------------------- other phrases ---------------------------- address, addr_p ;;= PATHNAME < address on local machine > URL < address on any machine > capability_name, cp_nm_p ;;= NAME < of capability type > right_hand_side, rhs_p ;;= rhs_qualifiers [type_name] variable_name rhs_qualifiers, rhs_ql_p ;;= [ 'LOCAL' | 'GLOBAL' ] [ 'RW' | 'RO' ] [range_expression] return_types_list, rt_tps_p ;;= type_name{, type_name}* type_name, tp_nm_p ;;= base_type built_in_type defined_type base_type, bs_tp_p ;;= 'BIT' | 'BYTE' | 'CHAR' | 'DEC' | 'GROUP' |; 'INT' | 'NAMELIST' | 'TYPE' | 'SUB' built_in_type, bi_tp_p ;;= < see http://www.MartinRinehart.com/posters/decaf-object-library.html > defined_type, def_tp_p ;;= < types defined in page or imported from other pages > variable_name, vr_nm_p ;;= NAME < word, type==NAME, textValue contains name > condition, cond_p ;;= logical_expression list_name, ls_nm_p ;;= NAME < that identifies a list, array, NAMELIST or group > self_name_p, self_p ;;= 'ME' #--------------------- statements ----------------------- statement, smt ;;= declaration_statement action_statement declaration_statement, dec_smt ;;= var_declaration_statement include_statement type_declaration_statement sub_declaration_statement action_statement, act_smt ;;= expression_statement block_statement if_statement foreach_statement while_statement loop_statement break_statement return_statement var_declaration_statement, vr_dec_smt ;;= rhs_qualifiers type_name variable_name include_statement, incl_smt ;;= 'INCLUDE' address {',' address}* type_declaration_statement, tp_dec_smt ;;= { 'CLASS' | 'CAPABILITY' } NAME1; [ 'EXTENDS' NAME2 ]; ['CANDO' capability_name [, capability_name]* ]; [ MULTILINE_STRING ] < documentation >; action_statement sub_declaration_statement, sb_dec_smt ;;= 'SUB' '(' [ list_expression ] ')' NAME '(' [ return_types_list ] ')'; action_statement expression_statement, exp_smt ;;= expression [ copula_operator right_hand_side{',' right_hand_side}* ] block_statement, blk_smt ;;= INDENT; [ MULTILINE_STRING ] < documentation >; statement*; UNINDENT if_statement, if_smt ;;= 'IF' condition 'THEN' action_statement [ 'ELSE' action_statement ] foreach_statement, for_smt ;;= 'FOR' 'EACH' variable_name IN list_name DO action_statement while_statement, whl_smt ;;= 'WHILE' condition 'DO' action_statement loop_statement, loop_smt ;;= 'LOOP' break_statement, brk_smt ;;= 'BREAK' return_statement, ret_smt ;;= 'RETURN' expression < expression may be expression_list > #---------------------- program ----------------------- program, prgrm ;;= [ MULTILINE_STRING ] < documentation >; statement*; END_OF_INPUT # end of decaf.bnf This is drifting off-topic. Unless someone (anyone?) else is interested, maybe we could do this via Email. MartinRinehart at gmail dot com.
  • How to add entities inside a group?

    6
    0 Votes
    6 Posts
    232 Views
    thomthomT
    Go ahead!
  • Script returns no errors but has no effect in sketchup

    9
    0 Votes
    9 Posts
    289 Views
    J
    @eric_erb said: I'm sure there is a big hint in your reply to my post but I just don't know enough to discern what you're telling me. No, I did not mean to say that. I replied to the wrong message - I should have tried more to answer the question.
  • Problem with Group name in SU 7.1

    6
    0 Votes
    6 Posts
    379 Views
    thomthomT
    definition.name is not the same as instance.name or group.name As you see when you select a ComponentInstance, in the Entity Info you see Name: and Definition Name: Same goes for the group, when you edit the Name: in the Entity Info you edit the ComponentInstance.name or Group.name - not the definition's name.
  • Trouble with .position_material method

    36
    0 Votes
    36 Posts
    5k Views
    F
    Thanks for carrying this on ThomThom. I think you're on to something here and I'm experimenting further. One of the complicating factors for me is that the face I want to apply texture to is often in a group which is in turn in a group (the wall file I posted earlier was a simplified version of what I'm doing). I notice that when I run the UVhelper script modified per your homogenous tip earlier, I get better UV values. I also notice that the real-world vertex positions are in global coordinates (returned from the face.outer_loop.vertices.each method). Conversely, when applying a texture, you need to use coordinates that are based on the local coordinate system that the face belongs to. I'm going to play around further. I've attached my modified uvhelper script. If what I said above is confirmed about local and global coordinates then I'll modify the uvhelper script further to report in local coordinates. uvhelper.rb
  • Removal of unwanted internal polys (lines)?

    5
    0 Votes
    5 Posts
    450 Views
    pilouP
    Problem is that the internal "square faces" are not coplanar! So ruby "remove inner face" cant work So you must ask a request in the Ruby section with a title like [REQ]Select internal lines don't believe that plug yet exist
  • Am I going nuts? [found, thanks]

    17
    0 Votes
    17 Posts
    1k Views
    E
    @ecuadorian said: Hi, Tomasz, thank you for your great work with the KT exporter. At the end I decided "Bring My View Back" was the quickest and most precise way to add a background. [...] I'll post a video tutorial soon for anyone interested. A bit late, but here it is: http://www.forums.sketchucation.com/viewtopic.php?f=18&t=22786
  • Production ruby for watercolor images

    6
    0 Votes
    6 Posts
    410 Views
    T
    Is this something that others would like? I have very limited ruby programing experience but I could look into it. thanks! s
  • Most efficient way [Ruby sollutions]

    2
    0 Votes
    2 Posts
    156 Views
    thomthomT
    Check this thread for performance info: http://forums.sketchucation.com/viewtopic.php?f=180&t=19576#p162235 I extended the test with more iterations: http://forums.sketchucation.com/viewtopic.php?f=180&t=19576&st=0&sk=t&sd=a&start=15#p166698 Basically: Avoid .typename as string comparison is slow. .is_a? and .kind_of? is aliases of the same method, they are both fast. In theory comparing .class should be quicker as the ruby source perform less calculations, but even with a large number of iterations there isn't much deviation from .is_a? / .kind_of? .
  • How can I determine entity level?

    15
    0 Votes
    15 Posts
    514 Views
    N
    Thanks thomthom, sorry... I was tired whed I read your post and I didn't understood exactly what you mean. But, Jim opened my eyes. Finally this is how I did it: model = Sketchup.active_model all_defs = model.definitions in_model = 0 out_model = 0 t1 = Time.new all_defs.each do |defn| count = defn.count_instances if count == 0 out_model += 1 else in_model += 1 end end t2 = Time.new dt = t2 - t1 puts 'time for completion; ' + dt.to_s puts 'all definitions; ' + all_defs.length.to_s puts 'in model; ' + in_model.to_s puts 'out_model; ' + out_model.to_s I was surprised that with 1600 component definitions , time for completion was 0.0
  • Ruby Essential Training release (Lynda.com)

    2
    0 Votes
    2 Posts
    2k Views
    JClementsJ
    FYI, you can play the video links for at least the introductory chapters. I haven't tried any others. Kevin does seem to be a good communicator.
  • Which are your favourite plugins?

    11
    0 Votes
    11 Posts
    914 Views
    jeff hammondJ
    Arc: Center and Two Points Weld Perpendicular Face Tools Arc Centerpoint Finder -or- Arc Centerpoint Invert Selection Skindigo Joint Push/Pull Bend (FredoScale) BoolTools (Selection Toys? what's that.. sounds like it could easily be added to this list if it can do what i hope it can )
  • Find vector closest to X_AXIS

    5
    0 Votes
    5 Posts
    168 Views
    thomthomT
    Great! Thank you very much!
  • Sketchup / ruby WebDiablog / php

    11
    0 Votes
    11 Posts
    718 Views
    P
    Nice so finally: the form will be in html and javascript, and the dialog between the html file and the ruby script will allow to do all queries. nice! and thx...
  • Idea/request/plugin

    4
    0 Votes
    4 Posts
    341 Views
    G
    TIG, I waiting for your Edge2Rails
  • Ruby system call

    6
    0 Votes
    6 Posts
    713 Views
    S
    Yes, that works. Thanks Jim.
  • [Code] Real UV from UVHelper data

    3
    0 Votes
    3 Posts
    2k Views
    thomthomT
    I believe so... I was having problems with my UV mirror plugin where I could not properly transfer distorted textures from one side to another. Scaled and skewed worked fine, as the Q value then returns 1.0 from the UVHelper - but distorted textures returned values with a Q value other than 1.0 - and that didn't play well when passing back to .position_material. This is what jeff99 said about this trials: @unknownuser said: I also think the q values is unused. The matrix is to transform from a 3D (xyz) point in model space, to a 2D (uv) point in image space. They just put the data in a Point3d because they didn’t have a Point 2D. If they are using homogeneous coordinates, the q value you are seeing may be the "H" value, and they should have divided the u and v values by H. (Do a Google search on homogeneous coordinates). I do however think that the U and V values are wrong. In our GeoSketch application we map areal images to faces. We calculate the UV coordinates in our code, and use position_material to map them to the face. The textures map to the faces correctly, and we see properly textured faces in the SketchUp model. After building the model, we have a tool to export to OpenFlight. We tried using the UVHelper to get the UV coordinates back, but when we applied them in OpenFlight, the textures didn’t map properly. Bummer. We then started storing our calculated UV coordinates as attributes on the face (the ones we used with position_material). Then we wrote these UV values to OpenFlight, and they worked perfectly. @thomthom said: H value? hm... this is new to me. I had another look at the values returned. Comparing the regular texture with the non-regular it seems that the UV values are multiplied by the Q value. Could it be that they multiplied instead of divided? If it is an H value, then I should be able to use that to restore the regular UV values? @unknownuser said: That would be very interesting. Let me know what you find. It would actually mean that they didn’t divide or multiply. For homogeneous transformations you are always supposed to divide by H. However, for some transformations, H comes out to be 1.0, so dividing doesn’t change the values. Your observation may mean that they didn’t divide by H. But we don’t even know for certain that they are using homogeneous coordinates. We need more information. @unknownuser said: Well Tom, I just changed my code on our theory that they did a homogeneous transformation, and the q value is actually the H value that they should have divided by. When I divided the u and v by q, and wrote those new values out, the textures mapped correctly. Your observation that the q value was not 1.0 for skewed projections was key. When H is 1.0, you get away with not doing the division. Thanks Tom, your diligence on this matter paid off. We can now compensate for it in our code. We just need to get Google to promise to tell us if they ever choose to fix this, and do the division by H. Let us know how your results are Dale.
  • OnPageChange event

    4
    0 Votes
    4 Posts
    289 Views
    chrisglasierC
    @chrisglasier said: And in Google SketchUp Ruby API what's the difference between PagesObserver.onContentsModified and PagesObserver.onElementAdded ... Now I have got to the point where I am checking what happens when the scene machine is plugged in to a model with no scenes. It is sensible to add one or more scenes to get started. But when I do that onContentModified sets off the JavaScript function for a scene selected from an existing set and throws an error. I suppose I will find a way round, but it does not seem right when there is " onElementAdded." There again I could have missed something fundamental. Either way I would appreciate some clarification. Thanks Chris
  • How to launch a ruby script with OnClick?

    8
    0 Votes
    8 Posts
    1k Views
    chrisglasierC
    @martinrinehart said: The message could also be actual Ruby code to execute, but there's a 2KB length restriction. I am sorry but I think this is misleading and my mother tongue is English. Is this what you are talking about? http://code.google.com/apis/sketchup/docs/ourdoc/webdialog.html @unknownuser said: Note that you're sending data down to Ruby as a single string that's passed via the window.location bar. In Internet Explorer on PC, there is a length limit of 2038 characters for this bar, so if you're needing to pass large data down you might consider using get_element_value to pull in a longer string from a hidden input field in the HTML.
  • Attributes object skectchup in a char variable in Ruby?

    3
    0 Votes
    3 Posts
    225 Views
    P
    Y i want create a script who can put in a ruby variables some attribute of my dynamic object when i click on him, but i don't know how to do this... I know c, c++, java, php 5 but sketchup and ruby is new for me . If you can help me, it's nice. thx

Advertisement