sketchucation logo sketchucation
    • Login
    1. Home
    2. qiucx
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Q
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 21
    • Groups 1

    Posts

    Recent Best Controversial
    • [plugin] xml parser

      I need to save the complex entity of SU to xml and then load them. REXML is too slow, and the libxml-ruby is really hard to compile. Does anyone have the working lib? Or other suggestion?

      thanks.

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      Thanks for all. The problem is done.

      The solution is to use ultraedit convert function(convert ascii to utf-8(unicode edition)). Originally, i use the notepad++ to convert utf-8 without BOM, and it seems not work as expected.

      Now, the split function can work correctly without any force_encoding, but the input from html should be converted using force_encoding("UTF-8").

      Thanks again for TIG.

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      I have set all files to UTF-8 without BOM.

      but the error remain:

      Error: #<ArgumentError: invalid byte sequence in UTF-8>
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:24:in `split'

      Can anyone have it? thanks.

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      BUT related files like the CSV [and HTML?] are also best when similarly encoded - but they are not.

      I have used the notepad++ to change the files encoding to UTF-8 without BOM.

      "also best when similarly encoded - but they are not" how can i to do this similarly encoded?

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      the files attached.


      userAttributes.csv


      UserManager.rb


      Login.zip

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      i find the solution but can not know the reason.

      fileline.force_encoding("ISO-8859-1").encode("utf-8", replace: nil)

      can anyone explain it? And does anyone have better solution?

      thanks.

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      thanks for your reply. Encoding::default_internal= "UTF-8" and Encoding::default_external= "UTF-8" are set in my entry main.rb and it works. the simple chinese character can be put correctly. However, when the split method can not work as expected. Following is the log and what is the problem with split method? thanks

      
      def getUsersInfoFromFile(fileName, path)
              arrayAttributes = Array.new
              pathAttrFile = Sketchup.find_support_file fileName, path
              if (pathAttrFile)
                  fileAttr = File.open pathAttrFile,"r;utf-8"
                  arrayFileLines = fileAttr.readlines
      
                  arrayFileLines.each do|fileline|
                      arrayFileLine = fileline.split ","
                      arrayAttributes << arrayFileLine
                  end
                  fileAttr.close
              end
              return arrayAttributes
          end
      
      

      also, when arrayFileLines = fileAttr.readlines is changed to arrayFileLines = fileAttr.encode("UTF-8").readlines, the problem remains and split error can be fixed when fileAttr.encode("ISO-8859-1").readlinesis used. can you explain? thanks again.

      Error:
      #<ArgumentError: invalid byte sequence in UTF-8>
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:130:in split' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:130:in readLines'
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:138:in getUsersInfoFromFile' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:27:in checkLogin'
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:97:in block in login' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:106:in call'
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:106:in show_modal' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:106:in login'
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/Main.rb:7:in <top (required)>' C:/remove/remove_SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in require'
      C:/remove/remove_SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in require' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD.rb:1:in <top (required)>'

      posted in Developers' Forum
      Q
      qiucx
    • Encode in 2014 again.

      My function reads the string from csv file with utf-8 without BOM and all rb file, html files are utf-8 too.

      Now, i using "File.open pathAttrFile, "r:utf-8"" to read the string file csv file having simple chinese encode content, my problem is that the function can not work when using "split" method directly for the read utf-8 string. "fileline.force_encoding("ISO-8859-1").split "," " should be used and it works. I do not know the reason, can anyone explain it? thanks.

      
                  fileAttr = File.open pathAttrFile, "r;utf-8"
                  arrayFileLines = fileAttr.readlines
      
                  arrayFileLines.each do |fileline|
                      attrs = fileline.force_encoding("ISO-8859-1").split ","
      .....
      
      

      And if i need to pass the iso8859-1 string to html, the string should be encoded to utf-8 using .encode("UTF-8") if defined?(Encoding).

      These convert is not very convenient, does anyone have simple method to address the issue?

      thanks

      posted in Developers' Forum
      Q
      qiucx
    • RE: Xml parser in sketchup

      Thanks for your reply.

      Unfortunately, i can not use DOM parser to do xml parsing.

      [edit]
      I have used the libxml and its performance is good enough for me. I setup the old version libxml and copy the ruby files, dll to plugin folder of sketchup, it works for me.

      posted in SketchUp Discussions
      Q
      qiucx
    • Xml parser in sketchup

      In my current project, REXML is used to parse the xml file containing information used by sketchup. However, REXML hurts the performance very much so that i have to consider another xml parse lib.

      From http://www.railstips.org/blog/archives/2008/08/11/parsing-xml-with-ruby/ we can see the http://xml4r.github.io/libxml-ruby/ is good choice, but i am not very familiar with this lib, does anyone have experience for this xml parser?
      BTW, my xml file is element base in general.

      posted in SketchUp Discussions sketchup
      Q
      qiucx
    • RE: How to erase the box of line in group

      The only way it won't show is to not select it.

      No, if i draw the line from point(0,0,0) to (x, 0 ,0), and add group to it, the bounding box wont show. I can draw a line from (0,0,0) and transform to the location which the user wants to draw and it can address my requirement. But it is too complex.

      posted in SketchUp Discussions
      Q
      qiucx
    • How to erase the box of line in group

      When we draw two connected lines and move one of them, the another line will be moved togather by SU. To ensure moving only one line, i add group for every line.
      Now the question is that when i select the line, the box of line group will be shown. How can we hide the box? It is very good if i can set the group properties to hide box during creating group for line.

      thanks for your reply.

      posted in SketchUp Discussions sketchup
      Q
      qiucx
    • RE: How to draw arc with three points

      Thanks all. The TIG tools is good enough for me.

      posted in SketchUp Discussions
      Q
      qiucx
    • How to draw arc with three points

      Now, i have the start, end point of arc and any other point in arc, and then, i need an algorithm to draw this arc. Does anyone has similar algorithm?

      From my understanding, we need to calculate the center point (the cross of two lines which is vertical with line [start point+other point] and [end point + other point]) and radius (the distance of center point and start point), it is a bit complex and i have no idea about next steps.

      I appreciate your reply. thanks

      posted in SketchUp Discussions sketchup
      Q
      qiucx
    • Inputbox change values.

      I have initialized a UI as
      UI.inputbox @arrayEquipmentPTNDataPrompts, @arrayEquipmentPTNDataDefaults, @arrayEquipmentPTNDataLists, @equipmentPTNInputBoxTitle

      arrayEquipmentPTNDataPrompts=['Country', 'province', 'city']

      My requirement is that when i select the country, the values of province will be changed related with the selected country, does anyone know how to address it?

      thanks

      posted in Developers' Forum
      Q
      qiucx
    • RE: Webdialogs for SketchUp ......RIP!

      I do not know SU three month ago and never use ruby for programming. I would like to share my idea of three month usage.

      1. Webdialog is great idea for ui and HTML5 will extend this advantage. The disadvantage is that the UI provided by SU is not so good.
      2. The shortage of SU is that the api functions are not powerful, i expect more api to operate the SU and the support for ruby is not up to date. I'd like to easy use of new version ruby api in SU.
      3. SU should consider to support the usage in ipad and andriod base system.
      posted in Developers' Forum
      Q
      qiucx
    • RE: Bat print skp files

      Thanks for your reply.
      I have updated my profile, and i use pc with windows xp/win7.
      And i need to pass the name of scene to print, every module has the same scene name. It look likes the layout of autocad.

      posted in Developers' Forum
      Q
      qiucx
    • Bat print skp files

      I have more than 200 skp files need to be printed, and it is nightmare to open them with SU one by one and clicking the print button. I plan to develop a tool which can read the skp file automatically and print it. Maybe, i need to add extra information to this skp before printing.

      Not sure if the plugin can address the requirment or need to call print driver mannually.

      Does anyone have this problem?

      I appreciate providing any tips for me.

      thanks

      posted in Developers' Forum
      Q
      qiucx
    • RE: How to load the system lib of ruby for SU

      Thanks for your reply.

      I solve this problem using the version 1.8.6 ruby and copying the rexml folder to plugins. As pointed by TT, the compatiblity is not good. the following code does not work:

      # Write the xml to file.
      #formatter = Formatters::Pretty.new(2)
      

      formatter.compact = true

      #File.open(path, 'w') { |result| formatter.write(doc, result) }

      and after changing to the following, it works:

      file = File.new(path,"w+")
      file.write(doc.to_s)
      file.close

      The reason is that the element.rb is not powerful so that the write function of document does not work.
      After converting the XML to string and write via File class, it works.

      posted in Developers' Forum
      Q
      qiucx
    • RE: How to load the system lib of ruby for SU
      1. If i copy the rb files from version 1.8.6 to plugin folder in SU, i will have the error as following, why doesnot the SU support ruby api 1.8.6? How to do it?

      w = PhysicalSiteXMLWriter.new()
      #PhysicalSiteXMLWriter:0xd56eac0
      p = PhysicalSite.new
      #PhysicalSite:0xcd8951c
      w.savePhysicalSiteToFile(p, 'aaaa.xml')

      Error: #<NoMethodError: undefined method <<' for #<Sketchup::Console:0xccbcc4c>> C:/SketchUp/Plugins/rexml/element.rb:676 C:/SketchUp/Plugins/rexml/document.rb:177:in write'
      C:/SketchUp/Plugins/rexml/document.rb:175:in each' C:/SketchUp/Plugins/rexml/document.rb:175:in write'
      C:/SketchUp/Plugins/PhysicalSiteXMLWriter.rb:371:in `savePhysicalSiteToFile'
      (eval):676

      posted in Developers' Forum
      Q
      qiucx
    • 1 / 1