sketchucation logo sketchucation
    • Login
    1. Home
    2. fredo6
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    Check out Febhouse | New extensions for Shadow Analysis in SketchUp Download
    fredo6F Offline
    • Profile
    • Following 0
    • Followers 70
    • Topics 175
    • Posts 5,452
    • Groups 3

    Posts

    Recent Best Controversial
    • RE: Solved: need help with groups and their names

      Sorry, I meant e.typename == 'Group'
      If you prefer to use class id, then you must NOT enclose it between quotes
      --> e.class == Sketchup::Group

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Solved: need help with groups and their names

      You should check the type too (e.type == 'Group') as there may be other drawing elements with the same name

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Select All Surfaces in a Model? Need assistance.

      Then you need to add one line of code (in the When 'Face' section)to change the "soft" property of the edges bording the faces. This slows down the script a little bit, but I undersatnd why you need it.

      
      def process_faces
      	model = Sketchup.active_model
      	model.start_operation "erase all faces"
      	process_faces_at_level model, {}
      	model.commit_operation
      end
      
      def process_faces_at_level(grp, hcomp)
      	list_entities = []
      	grp.entities.each do |entity| 
      		case entity.typename
      		when 'Group'
      			process_faces_at_level entity, hcomp
      		when 'ComponentInstance'
      			edef = entity.definition
      			next if hcomp[edef.to_s]
      			hcomp[edef.to_s] = edef
      			process_faces_at_level edef, hcomp
      		when 'Face'
      			list_entities.push entity  # or do what you want with the face
      			entity.edges.each { |e| e.soft = false } #Keep smooth edges
      		end
      	end
      	grp.entities.erase_entities list_entities
      end	
      
      
      
      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Select All Surfaces in a Model? Need assistance.

      I am not clear on what you want.
      Do you want to keep faces which have at least one edge smoothend or softened?
      Or do you want to change the property of these edges, and still erase all faces?

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Select All Surfaces in a Model? Need assistance.

      If you need to earse all faces at all levels, then you must do it differently
      Here is a code sample

      
      def process_faces
      	model = Sketchup.active_model
      	model.start_operation "erase all faces"
      	process_faces_at_level model, {}
      	model.commit_operation
      end
      
      def process_faces_at_level(grp, hcomp)
      	list_entities = []
      	grp.entities.each do |entity| 
      		case entity.typename
      		when 'Group'
      			process_faces_at_level entity, hcomp
      		when 'ComponentInstance'
                              edef = entity.definition
      			next if hcomp[edef.to_s]
      			hcomp[edef] = edef
      			process_faces_at_level edef, hcomp
      		when 'Face'
      			list_entities.push entity  # store faces in the list
      		end
      	end
      	grp.entities.erase_entities list_entities #or do what you want with the faces
      end	
      
      

      Note the specific treatment of component instances, as you must delete the face only once in its definition (which will propagate then to all instances)

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Select All Surfaces in a Model? Need assistance.

      Here is a simple code to select all faces at the model level

      
      def select_all_faces
              model = Sketchup.active_model
              model.selection.clear	#empty the current selection
              model.entities.each { |e| model.selection.add e if e.typename == 'Face' }
      end
      
      

      Note that you cannot select entities at different levels, for instance in the first level of the model and at the same time within groups or component instances

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: How can I store binary data in an attribute

      @unknownuser said:

      ps Fred, if you are saving 3D points as attributes - what happens when a user moves the spline?

      Very interesting question, that I did not ask myself (actually, I just inherited the method from the previous bezier.rbscript by @Last). But magically, it seems to work fine, whether you move, scale or rotate the curve.

      There must be a trick!

      But this macro is full of surprise, for instance with an undocumented method "curve.move_vertices", which allows moving the vertices of a curve without having to recreate one.

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: How can I store binary data in an attribute

      I had the same problem with binary strings, because Sketchup stops the decoding at first \0 character.

      But if you just wish to store an array of fixnum, why don't you store it 'naturally'. Sketchup entity attributes does it well, back and forth. I used this for my bezierspline.rb macro, where I do store arrays of 3D-points in this way.

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Keyboard translation PC / Mac

      Thanks very much Todd.

      There are strange things on the Mac, like the fact that several keys (alphas and numpad) do nt seem to be trapped on the KeyDown, but only on the KeyUp event. This is also the case for Tab, Del and Backspace. This may be due to the VCB interference.

      I'll see what I can do.

      Thanks again

      Fredo

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Keyboard translation PC / Mac

      Thanks.
      For the time being, I will follow your advice (and also use File.join instead of building the string with /

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Keyboard translation PC / Mac

      @unknownuser said:

      how about using Sketchup.find_support_file "Plugins" and then File.join(Plugins_dir, filename) ?

      This works on Windows as well.
      My problem is know whether this works on Mac, since I have no Mac and I have not even seen Sketchup running on a Mac!!

      Are you Mac User? If so,could you just cnfirm this works fine? Thanks in advance.

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Keyboard translation PC / Mac

      Todd,

      Thanks for the offer.
      Here is the script KeysForMac.rb. It adds a menu item "Prompt for Mac keys" in the Plugins menu. When you invoke it, you will be notified on which key to type in the Status bar. The test takes less than 3 minutes.

      It normally generates a small text file KeysForMac.txt, which normally should end up in your folder equivalent on MAc to C:\Program Files\Google\Google SketchUp 6. Actually I just open the file with no directory reference, because this is another potentialproblem on Mac.

      	fname = "KeysforMac.txt"
      	f = File.new fname, "w"
      
      

      Talking about Directory and file paths on Mac, I have another problem with my method to find script files in the Plugins Directory. On Windows, I use the following statements:

      BZ___DirSU = Sketchup.find_support_file ".", "."
      BZ___SearchDir = Dir["#{BZ___DirSU}/Plugins/BZ__*.rb"]
      
      

      But it does not seem to work. Maybe you can find out what I should use instead on Mac.

      Again many thanks for your proposal.

      @unknownuser said:

      Example of file generated (here on Windows XP)
      http://www.sketchucation.com/forums/scf/sas/Ruby/KeysforMac.txt

      Small macros for capturing keys.
      To dropin Plugins folder
      http://www.sketchucation.com/forums/scf/sas/Ruby/KeysforMac.rb

      Fredo

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Keyboard translation PC / Mac

      Thanks very much in advance Todd.

      On my Windows XP laptop, I have this:

      On the platform
      PLATFORM = i386-mswin32
      RELEASE_DATE = 2003-08-04
      RUBY_PLATFORM = i386-mswin32
      RUBY_RELEASE_DATE = 2003-08-04
      RUBY_VERSION = 1.8.0
      VERSION = 1.8.0

      On the Keyboard
      ALT_MODIFIER_KEY = 18
      ALT_MODIFIER_MASK = 32
      CONSTRAIN_MODIFIER_KEY = 16
      CONSTRAIN_MODIFIER_MASK = 4
      COPY_MODIFIER_KEY = 17
      COPY_MODIFIER_MASK = 8

      VK_ALT = 18
      VK_COMMAND = 18
      VK_CONTROL = 17
      VK_DELETE = 46
      VK_DOWN = 40
      VK_END = 35
      VK_HOME = 36
      VK_INSERT = 45
      VK_LEFT = 37
      VK_MENU = 18
      VK_NEXT = 34
      VK_PRIOR = 33
      VK_RIGHT = 39
      VK_SHIFT = 16
      VK_SPACE = 32
      VK_UP = 38

      On the Mouse control
      MK_ALT = 32
      MK_COMMAND = 0
      MK_CONTROL = 8
      MK_LBUTTON = 1
      MK_MBUTTON = 16
      MK_RBUTTON = 2
      MK_SHIFT = 4

      Still no idea about the other keys on Mac, and the difference between the concept of CONSTRAIN_MODIFIER_MASK and CONSTRAIN_MODIFIER_KEY.

      posted in Developers' Forum
      fredo6F
      fredo6
    • Keyboard translation PC / Mac

      It seems that there is at least a big difference between the two platforms in this area. So I would be grateful to a Mac user to advise on the principle to find out keys codes returned by the onKeyDown method on Mac.

      Pixero indicated to me the following codes on Mac
      Command/"Apple" = 1048576
      Alt/Option = 524288
      Control = 262144
      Arrow Left Key = 63234
      Arrow Right Key = 63235
      Arrow Up Key = 63232
      Arrow Down Key = 63233
      Shift Key = 131072

      But what about the regular alphabetic characters, the function keys, and the punctuation signs?

      Ideally, someone having both platforms should be able to establish the correspondance, and possibility write a small utility routine to 'unify' the keys between the two systems (unless this already exists!). I can do it, if someone gives me the list.

      Also, I'd like to know the rules for the value on Mac of the constant RUBY_PLATFORM, which apparently allows to detect which platform you run on. For Mac, I know at least the value 'powerpc-darwin'. However, what happens on more recent Macs, running on Intel and Leopard (I understand from an earlier post from Todd Burch, that there should anyway be the string 'darwin' in the constant).

      I am sure this will be helpful to the Sketchup Community, to make sure that scripts released can fonction both on Mac and PC.

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: BeizerSpline - Latest version (obsolete)

      @fletch said:

      So one tiny request (hopefully tiny) is there a way you could, after selecting the first point for the polyline tool, one could right-click and choose 'lock Z axis' and in this way it would draw all other points forcing them to match the exact elevation of the initial point? (This would be very handy for 'tracing' in plan view over the top of difficult geometry that one cannot seem to close/create a face from no matter what one does.)

      The option exists actually. When you draw a curve the default behavior is to force all points on the plane defined by the first 3 points (cursor is a black square). However, if you press the Up Arrow (i.e. blue axis), the points of the curve will be forced on the horizontal plane defined by the first point (cursor is a blue square). This works as well for the 2 other axis planes.

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Support of Language translation - LibTraductor.rb

      It's easy anyway to replicate LangHandler with your own version you control (and anyway a GetString method that takes a default in case the string is not found).

      My observations were that it's seems that the community of Ruby 'scripters' prefer to avoid proliferation of files and deliver extensions with one or very few files.

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Support of Language translation - LibTraductor.rb

      Several remarks:

      1. you are definitely right. It is more elegant with a separate file, so that you can proceed with the translation without touching anything in the code itself

      2. the Sketchup Ruby documentation is really poor 😞 . I did not know LangHandler, and furthermore, that it was provided in the standard tool librairies of Sketchup. The script itself is not commented. I am sure many of us would appreciate if the Sketchup team could improve the doc.

      3. I will indeed adapt LibTraductor to manage strings in external files, in order to keep the additional functions I wrote on dialog boxes.

      Thanks a lot for signaling this to me.

      By the way, I never found a Sketchup macro that had a separate 'string' file, but instead I found many that were published as several versions of the same macro translated within the code (like bezier.rband fr_bezier.rb, also written by the same @Last Software). Is this because Sketchup Ruby programmers don't really bother, or because nobody knows really about LangHandler?

      posted in Developers' Forum
      fredo6F
      fredo6
    • Support of Language translation - LibTraductor.rb

      When I designed the script bezierspline.rbI indeed bumped into the problem of language translation, both as a script programmer and as a script user. I made some research on what existed in terms of practices and tools and found very little. In general, scripts are written in a single language (English usually), and then the script is converted by someone into other languages, by modifying strings in the code and renaming the script file. For instance you have bezier.rband fr_bezier.rbon the Crai Ruby Depot.

      There are a few issues with this approach:

      • Having several versions of the file makes it more difficult to keep potential upgrades and bug fixing in sync.
      • Some errors can be made when translating strings embedded in the source code. You can forget to translate some, or accidentally translate strings that you should not.

      So I came up with this small library LibTraductor.rband a set of practices to rationalize a little bit the coding and the language translation management of Sketchup scripts.

      The principle is to provide a way to define and use strings that carry their own translated version.

      
      Mystring = "Hi |EN| Welcome  |DE| Wilkommen |FR| Bienvenue"
      
      

      The macro provides utility functions to support:

      • The definition and usage of multi-language strings, including substitution patterns with %1, …, %9
      • Mass assignment of string constants to variables
      • The designing of dialog boxes, with language translation and built-in validation
      • A few utilities on hash arrays (marshaling, un-marshaling, pretty print)

      Usage: just drop the macro file LibTraductor.rbin the Plugins folder of Sketchup, and in your script just insert a statement:
      require "LibTraductor.rb".

      Test utility: I published a test macro LibTraductor_test.rbto show some examples. It adds 4 menu items in the Plugins menu of Sketchup.

      Compatibility: the macro should work with Sketchup v5 and v6 (Pro and free versions, English and French). I tested it on Windows XP and Vista. I don't know however if it works on Mac

      Programming manual of the Traductor library:
      http://www.sketchucation.com/forums/scf/sas/Ruby/Tutorial%20Traductor%20-%20v1.pdf

      Test utility for LibTraductor:
      http://www.sketchucation.com/forums/scf/sas/Ruby/LibTraductor_Test.rb

      Script library to drop in Sketchup Plugins folder:
      http://www.sketchucation.com/forums/scf/sas/Ruby/LibTraductor.rb

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: Get_locale

      Strange things actually.
      On a PC with Windows XP in French, Sketchup v6.0.277, I get the following:
      Sketchup.get_locale --> "FR"
      Skectup.os_language --> "EN" (so two characters only).

      On another laptop, with Windows XP US International version and Sketchup v6.0.515, I get:
      Sketchup.get_locale --> "EN"
      Skectup.os_language --> "EN" (so two characters only).

      So this new behavior you report seems pretty recent.

      posted in Developers' Forum
      fredo6F
      fredo6
    • RE: International characters

      This is normal. For German characters, you do not need Unicode. So you should swith it off.
      For MSVC, I don't know if there is an efficient way to enter the extra characters. I am personally using Notepad++.

      posted in Developers' Forum
      fredo6F
      fredo6
    • 1
    • 2
    • 269
    • 270
    • 271
    • 272
    • 273
    • 272 / 273