sketchucation logo sketchucation
    • Login
    1. Home
    2. mgate
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 7
    • Groups 1

    mgate

    @mgate

    10
    Reputation
    1
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    mgate Unfollow Follow
    registered-users

    Latest posts made by mgate

    • RE: Copying files using "ftools.rb" library

      The goal is to create a copy of two existing template files (not opened) from "Resource" folder to a different path, the target files should have new names too (previously defined in a inputbox).
      templates:
      ...\Resources\XXX AT Template.skp
      ...\Resources\XXX AT Template.xlsx

      Here it is part of the script of my plugin, at the moment just trying to copy the skp file though:

      require 'ftools.rb'
      ...
      ...
      folder		= File.dirname( __FILE__ )
      resources	= "Resources"
      resource_name= "XXXXXX AT Template.skp"
      resource_file	= File.join(folder, resources, resource_name).tr("\\","/") # the script will be modified to select the directory via a UI.savepanel dialogue
      file_name	= "123456 AT aa.bb.skp"  # the real name will be picked via an inputbox
      desti_file	= File.join(folder, file_name).tr("\\","/")
      
      if File.exist?(resource_file)
       File.copy(resource_file, desti_file, verbose = true)
      else
       puts "SKETCHUP TEMPLATE FILE NOT FOUND!"
       return nil
      end
      ...
      ...
      
      

      The above script certainly creates the copy in the correct folder but SU crashes afterwards.

      As the move() doesn't crash, I tried to modify it as follow:

        def move(from, to, verbose = false)
          to = catname(from, to)
          $stderr.print from, " -> ", to, "\n" if verbose
      
      #    if RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ and file? to
      #      unlink to
      #    end
          fstat = stat(from)
          begin
      #     rename from, to
      #  rescue
            begin
            ln from, to and unlink from
            rescue
      	from_stat = stat(from)
      	syscopy from, to  and unlink from
      	utime(from_stat.atime, from_stat.mtime, to)
      	begin
      	  chown(fstat.uid, fstat.gid, to)
      	rescue
      	end
            end
          end
        end
      
        alias mv move
      

      by using above move(), the resource_file is kept and the desti_file is created but SU crashes too.

      I tried to use Fileutils.rb instead but there are lots of errors when open SU v.8 (I'm using !AdditionalPluginFolders.rb) and below doesn't work:

      FileUtils.copy_file(resource_file, desti_file, preserve = false, dereference = true)
      
      posted in Developers' Forum
      M
      mgate
    • Copying files using "ftools.rb" library

      I aim to copy a SketchUp file from one folder to another. I'm using the following method from the "ftools.rb" library:

      def copy(from, to, verbose = false)
          $stderr.print from, " -> ", catname(from, to), "\n" if verbose
          syscopy from, to
        end
      
        alias cp copy
      

      when running my plugin, the file is copied correctly from the original folder to the destination folder but SketchUp crashes afterwards.

      @unknownuser said:

      SketchUp Application has stopped working
      A problem caused the program to stop working correctly.
      Windows will close the program and notify you if a solution is available.

      I tried different options, i.e. keeping the same "to" file name as the "from", also changing it but SketchUp always crashes.
      However, when using the move method of the "ftools.rb", it works perfectly with no problem even changing the "to" name:

        def move(from, to, verbose = false)
          to = catname(from, to)
          $stderr.print from, " -> ", to, "\n" if verbose
      
          if RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ and file? to
            unlink to
          end
          fstat = stat(from)
          begin
            rename from, to
          rescue
            begin
              symlink readlink(from), to and unlink from
            rescue
      	from_stat = stat(from)
      	syscopy from, to and unlink from
      	utime(from_stat.atime, from_stat.mtime, to)
      	begin
      	  chown(fstat.uid, fstat.gid, to)
      	rescue
      	end
            end
          end
        end
      
        alias mv move
      

      Any idea where the problem is? Thanks for your time.
      Note: I use SU v8

      posted in Developers' Forum
      M
      mgate
    • RE: [Plugin] SolidSolver

      Great!! SolidSover v.08 works fine with SKU8.
      Thanks for your quick reply. Cheers!

      posted in Plugins
      M
      mgate
    • RE: [Plugin] SolidSolver

      Hi Tig,
      I get below issue when installing SolidSolver v7.0 in my SKU8 Free (ver.8.0.16846):

      @unknownuser said:

      Error Loading File C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/TIG-solidsolver/TIG-solidsolver_code.rb
      undefined method force_encoding' for "langhandler.rb":StringError Loading File TIG-solidsolver.rb undefined method force_encoding' for "langhandler.rb":String

      Any solution to fix it?
      Thanks for your time.

      posted in Plugins
      M
      mgate
    • RE: [Plugin] FreeDXF Importer

      neither working if commented out the "fileutils" line.

      I have a folder with two files in dxf and dwg formats:
      snapshot of folder with dwg and dxf files
      Once opened the "FreeDXF v.0.11.2" pop-up window, there is only the dxf file (the dwg file is not available):
      snapshot of FreeDXF pop-up window

      Is there a problem with "extra extensions"?

      def self.select_file(extra_extensions = "")
            title     = 'FreeDXF Select DXF File'
            directory = nil
            # filename  = 'DXF|*.dxf|DWG|*.dwg||'
            filenames = "Cad Files|*.dxf" + extra_extensions + "||"
            file_path = UI.openpanel(title, directory, filenames)
            if file_path.nil?
              return nil
            else
              file_path.tr!('\\', '/')
              @last_selected_file = file_path
              return file_path
            end
          end
      
          def self.main
             puts "\nFreeDXF debugging ON." if $JFDEBUG
             extra_extensions = Teigha.available? ? ";*.dwg" ; ""
             file_path = select_file(extra_extensions)
             return if file_path.nil?
             #file_path.downcase!
             if file_path.end_with?(".dwg")
                Teigha.dialog()
                file_path = Teigha.convert(file_path)
                if file_path.nil?
                   puts "dxf file was not created."
                   return
                end
             end
      

      Any idea how to solve?
      Another way is to convert dwg files manually with TeighaFileConverter, and then use FreeDXF plugin in SKU.
      Sorry to snoop around your codes ๐Ÿ˜

      posted in Plugins
      M
      mgate
    • RE: [Plugin] FreeDXF Importer

      @driven said:

      are you importing from the Extensions or File menu item ?
      john

      through the Extensions (the dwg format is not available in FreeDXF Importer plugin)

      I looked into the Ruby file "teigha.rb". Is it required an additional file or library called "fileutils"? If so, that file is missing inside "jf-freedxf" folder.

      require "fileutils"
      
      module JF
        module FreeDXF
          module Teigha
      
            # Teigha Command Line Format is;
            #   Quoted Input Folder
            #   Quoted Output Folder
            #   Output_version {"ACAD9","ACAD10","ACAD12", "ACAD13","ACAD14", "ACAD2000","ACAD2004", "ACAD2007","ACAD2010"}
            #   Output File type {"DWG","DXF","DXB"}
            #   Recurse Input Folder {"0","1"}
            #   Audit each file {"0","1"}
            #   [optional] Input file filter (default;"*.DWG;*.DXF") (Use File.basename(filename))
      
             if Sketchup.platform == ;platform_win
                EXE = "C;/Program Files (x86)/ODA/Teigha File Converter 4.01.0/TeighaFileConverter.exe"
             else
                EXE = "/Applications/TeighaFileConverter.app/Contents/MacOS/TeighaFileConverter"
             end
      

      In my WIN 8.1 Pro, the Teigha sofware is installed in the default folder too:

      C;/Program Files (x86)/ODA/Teigha File Converter 4.01.0/TeighaFileConverter.exe
      

      Cheers!

      posted in Plugins
      M
      mgate
    • RE: [Plugin] FreeDXF Importer

      First of all, thanks a lot for your plugin, Jim.

      Just a query about the Teihga converter.
      The dwg import option doesn't work (with SKU 2015 Make and latest FreeDXF v.0.11.2).
      The Teigha has been installed in the default folder, and works fine. However, in SKU when I try to import a dwg file, that format is not available in the dialog box (only the "Cad files" option for dxf files), as if the plugin doesn't grab the converter.

      Does anyone solved the same issue?

      Many thanks in advance for your help.

      posted in Plugins
      M
      mgate