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

    Posts

    Recent Best Controversial
    • Extension creation code

      I have the following problem with the extension installation in Sketchup 2016:

      I use the following code to load my plugin:
      ` # Load the normal support files.
      require 'sketchup.rb'
      require 'extensions.rb'

      Create the extension.

      ext = SketchupExtension.new('pluginName', File.join('pluginFolder', 'pluginLoader.rb'))

      Attach some nice info.

      ext.creator = 'xxxxx'
      ext.version = '1.0.0'
      ext.copyright = '2016, xxxxxxxx'
      ext.description = 'xxxxxxxxxxxxxxxxxxx'

      ext.extension_path=File.join(File.dirname(FILE), "pluginFolder" )

      Register and load the extension on startup.

      Sketchup.register_extension(ext, true)`

      The Preferences/Extension Window then shows 2 entries for my plugin, one with the name of the pluginFolder and one with the pluginName. Only the entry with the pluginName shows also the plugin details.
      When I delete the ext.extension_path entry in the above code, everything seems to be OK.
      As I use the ext.extension_path in my loader file I need to fix this problem, which did not occur in previous Sketchup Versions.

      Help is very much appreciated

      posted in Developers' Forum
      S
      sonjachr
    • RE: Move group to left corner of screen

      Wow! This is awesome! It works!

      Thanks a lot.
      I almost gave up!
      Good to know, that there are real experts in this forum who are willing to help.

      Thanks again.

      posted in Developers' Forum
      S
      sonjachr
    • RE: Move group to left corner of screen

      I can ' t ask the user to triim the image by himself, before my code is going to put it as a texture onto a terrain.

      Any further ideas?

      It seems to be the last open issue in my routine, so I am very eager to get this solved.

      Thanks for your help

      posted in Developers' Forum
      S
      sonjachr
    • RE: Move group to left corner of screen

      Thanks for your help,

      • I draw a simple rectangle
        Then I tried:
      Sketchup.send_action(10519)  #Change to a non-perspective Camera.
      Sketchup.send_action("viewTop;")  #Change to a Plan view.
      Sketchup.send_action("viewZoomToSelection;") #Zoom extents of the Selection.
      
      
      

      Unfortunately I still have the annoying green borders as shown in the below Image. Can anybody try it and come back with his/her Image.

      I have no clue what is wrong.

      Help is very much appreciated


      Unbenannt.png

      posted in Developers' Forum
      S
      sonjachr
    • RE: Move group to left corner of screen

      Thanks Dan for the quick reply.
      I tried it before, but what I get is the below Image. I need an Image without the green borders at the left and at the top..


      Mer_Bie_01_interpol.png

      posted in Developers' Forum
      S
      sonjachr
    • Move group to left corner of screen

      Hallo, I need your help on above issue.

      I want to perform a view.write_image of a selected Group with coloured faces and use this Image as texture for a Terrain.

      The only way I found to apply the Image to the Terrain in a proper way, is by
      aligning the group to the left/upper side of the screen before writing the Image.

      Otherwise the Image contains uncolored portions to the left and the top of the Image.

      I tried to move the Group to the upper left Corner using the following code:

      model = Sketchup.active_model 
      @view = model.active_view 
      
      keys = { 
      	;filename => @chosen_file,
      	;width => @view.vpwidth, 
      	;height => @view.vpheight,
      	;antialias => false, 
      	;compression => 0.9, 
      	;transparent => true 
      } 
      	
      ip0=@view.inputpoint(0,0)
      ip1=@view.inputpoint(@view.vpwidth,0)
      p0=ip0.position
      p1=ip1.position
      sel= model.selection
      bbox = sel[0].bounds
      sel[0].move! [p0.x+bbox.width/2,p0.y-bbox.height/2,0]		
      view.write_image keys	
      view.invalidate
      
      

      Unfortunately this does not work reliable.

      Any better ideas? Maybe there is even a more simple solution.

      Very much appreciate your help!

      posted in Developers' Forum
      S
      sonjachr
    • RE: Apply images to terrain using ruby code

      Many Thanks,
      this works, I really appreciate your help!
      I feel ashamed as I should have found the solution by myself. I will try to work harder on my Sketchup/Ruby knowledge, but I will never become an expert as you are.

      posted in Developers' Forum
      S
      sonjachr
    • RE: Apply images to terrain using ruby code

      Thanks a lot for the quick response.

      Your code is working perfectly.

      However I've got a further problem and thus a new question. I am sure it is easy for you, but it is hard for me to get the right solution. I searched a lot in the Forum but did not find an answer to my problem.

      When I load the below image and run your code to apply the image to the terrain I get what you see in the second image.
      image to be loadedTerrain with texture

      Using a different image works fine, so I guess my image export was not done correctly.
      Do you have any ideas?

      Many Thanks in advance

      posted in Developers' Forum
      S
      sonjachr
    • Apply images to terrain using ruby code

      I found the following instruction in SU documentation:

      Apply images to terrain models:

      Import an image as an object by going to file > import and leave the "use as texture" box unchecked.

      Scale and position the image over the site plan so it is properly aligned. Right click on the image and choose Explode. Using the Paint Bucket, Alt-click on the image to pick up the material, then click on any part of the terrain to project the image down onto the terrain surface.

      I almost managed to code it in ruby, but I am stuck when it comes to the Alt-click.
      My question: how can I send the Alt-click using ruby or how can I sample the image using ruby

      Help is very much appreciated

      posted in Developers' Forum
      S
      sonjachr
    • RE: Start_operation/commit_operation with sandboxTools

      Thanks Tom for your advice to contact Fredo.
      I have contacted him and he told me that he could provide an API, which could solve my problem, hopefully.

      posted in Developers' Forum
      S
      sonjachr
    • RE: Win32ole access violation

      Thanks for the reply.
      The messagebox was just a simple example. What I want is to use some complex vb.net forms, which do already exist as a frontend for a calculation System.
      I can invoke all functions in this calculation System using win32ole, but just not those showing forms and messageboxes. It does work with Sketchup 2013, where I can use a win23ole.so , located in my plugins folder. But with Sketchup 2014/2015 I have to use the win23ole.so shipped with Sketchup. I have no clue how to solve this Problem.
      Help is very much appreciated.

      posted in Developers' Forum
      S
      sonjachr
    • RE: Start_operation/commit_operation with sandboxTools

      Thanks again for your reply.
      I looked into the source code of Fredos Lib and TopoShaper Plugin. Even if Fredo would allow me to use some of his source code it would be much too complicated for me to pick the right code to generate the Terrain. It seems to be a very complicated and powerful tool.
      Do you know, whether the source code of the sandbox FromContoursTool is available?

      I feel a little helpless, as I am not a ruby expert. Any further ideas? Otherwise I have to ask the user to create the Terrain manually using the Sandbox Tools.

      posted in Developers' Forum
      S
      sonjachr
    • RE: Start_operation/commit_operation with sandboxTools

      Thanks for the quick reply.
      the code shown in my question ist just an extract. In the original code I have an errorhandling, telling the user to switch on the Sandbox Tools.

      I am working on a plugin where the user may use Google Earth to import a Google Earth Terrain, extracting contour lines on a certain layer, selecting all the contour lines and building a Terrain on a certain layer using the Sandbox Tools, grouping it and setting some attributes to the group, and finally making the contour lines invisible. The layers and the attributes are needed for further processing.
      Besides the Import of the Google Earth Terrain, everything is done in a module without user interaction and therefore should be undone in one go.
      I don't have any idea how to get this done without using the Sandbox Tools.

      Can you help me please.

      posted in Developers' Forum
      S
      sonjachr
    • Start_operation/commit_operation with sandboxTools

      I Need to use the sandbox Tools to generate a Terrain from Contour lines, which have to be selected Prior to the Operation. It is a requirement of the Sketchucation warehouse , that the user Action has to be undone in one go. So, for the example code below, it should be just the undo Terrain1.
      However when I run the below code (in the Ruby Code Editor), I get two undos: **Sandbox Utilites and Terrain1

      What is wrong with below Code?
      I have attached a simple skp File, with a contour layer**
      [pre:1rxq2znq]` model = Sketchup.active_model # Open model
      layers = model.layers
      model.start_operation("Terrain1",false,false,false)

      new_layer = layers.add "Terrain"
      
      activelayer = model.active_layer = layers["Terrain"]
      

      model.commit_operation
      model.start_operation("Terrain2",false,false,true)
      begin
      if (Sketchup.version.to_f <14.0)
      tr=model.select_tool FromContoursTool.new
      else
      tr=model.select_tool Sketchup::SandboxTools::FromContoursTool.new
      end
      model.commit_operation
      rescue

      	model.abort_operation
      	return
      	
      end 
      
      begin
      

      model.start_operation("Terrain3",false,false,true)
      layers.each do |la|

      	  if la.name == "Contour"
      	  	 la.visible=false
      	  end
      	end	 
      

      model.commit_operation
      rescue
      model.abort_operation
      end`[/pre:1rxq2znq]

      Thanks in advance for your help


      simple skp with contour layer

      posted in Developers' Forum
      S
      sonjachr
    • Win32ole access violation

      I am having problems with win32ole, using Sketchup 2014, 2015
      I get the following error message:

      Error: (in OLE method AddMyValues': ) OLE error code:80004003 in mscorlib Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist. HRESULT error code:0x80020009 Exception occurred. C:/Users/Christiansen/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/sci_noise3donline/sci_menu_methods.rb:791:in method_missing'

      Ruby Code:

      ` require 'sci_noise3donline/Desktop/win32ole.so' if Sketchup.version.to_f <14
      require 'win32ole' if Sketchup.version.to_f >13

      lib = WIN32OLE.new('ClassLibrary1.MyFunctions')
      tt=lib.AddMyValues()
      puts tt`

      VB.net code: for ClassLibrary1.dll
      [pre:1774dfzw]Imports System.Windows.Forms
      Public Class MyFunctions
      Public Function AddMyValues()
      Dim Result As Double
      Result = 20
      MessageBox.Show(Result)
      Return Result
      End Function
      End Class[/pre:1774dfzw]

      ClassLibrary1.dll is registered and visible

      it is working in Sketchup 2013 even with MessageBox.Show(Result)
      and it is working in Sketchup 2014, 2015 when I eliminate MessageBox.Show(Result)

      Any ideas?

      Your help is very much appreciated

      posted in Developers' Forum
      S
      sonjachr
    • RE: RBZ installation on MAC OS

      Hi John,
      many thanks for your quick reply.

      It was really helpful. I am now using the command line of winzip in my Powershell script, as you have proposed. The generated RBZ file is now working on my MAC also.

      Thanks a lot for your help.

      Sonja

      posted in Developers' Forum
      S
      sonjachr
    • RBZ installation on MAC OS

      I am generating my RBZ file using a Powershell script on my Windows PC, by collecting all plugin files, doing scrambling and then zip the files and rename to RBZ

      [pre:14foiw11][Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" )
      $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
      [System.IO.Compression.ZipFile]::CreateFromDirectory( $srcdir, $zipfilename, $compressionLevel, $True)
      Copy-ToZip $srcdir -ZipFile $zipFilename[/pre:14foiw11]
      Installation of the RBZ file works fine on my Windows PC, but on the MAC it fails.
      When I unzip the file and zip it using Winzip, the Installation on the MAC is working.

      So, I guess, some of my parameters in the Powershell zip routine may be wrong.

      Anybody having an idea what is wrong?

      Help is very much appreciated!

      posted in Developers' Forum
      S
      sonjachr
    • RE: Problem with modules and classes: undefined method

      **It works!**Thanks a lot, you saved my weekend!

      posted in Developers' Forum
      S
      sonjachr
    • RE: Problem with modules and classes: undefined method

      thanks for the quick answer. Unfortunately the c=round(pre) is not working for Sketchup2013 (wrong number of arguments (1 for 0)), it is only working for Sketchup2014.

      It is my understanding, that I have to include the class in my root Namespace to get my Extension included in the Sketchucation warehouse. It is the only class I am having problems with.

      I really need help on this.

      Thanks

      posted in Developers' Forum
      S
      sonjachr
    • Problem with modules and classes: undefined method

      Need help on this problem, please:

      [pre:25n9k511]module TEST
      class Numeric
      def precision(pre)
      return self.truncate if pre == 0
      mult = 10.0 ** pre
      (self * mult).round.to_f / mult

      end
      

      end
      a=123.4567
      c= a.precision(2)
      end #module[/pre:25n9k511]
      getting the following error: "undefined method `precision' for 123.4567:Float"

      your help is very much appreciated

      Thanks

      posted in Developers' Forum
      S
      sonjachr
    • 1 / 1