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

    Posts

    Recent Best Controversial
    • RE: Ruby array to hash

      Thanks TIG it is a good point πŸ˜„

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Ruby array to hash

      Thanks TIG your generous script prints out unique arrays and it is not realy the exact case.

      thomthom -> name, value
      h{"name" => value, "name" => value,}

      Looks like I havn't told all the details.

      1. I have multidimensional array[] in Ruby
      2. I want to send array[] to Webdialog using dialog.execute_script()
      3. I want to send to PHP and arrange and do stuf with array[]

      My array[] looks like this array[[value1, value2, value3,...],[value1, value2,...],...]

      Im trying to transform array[] to hash{}
      hash{0=>[0_0=>value1,0_1=>value2,0_2=>value3,...],1=>[1_0=>value1,1_1=>value2,...],...}

      maybe I don't need transform, maybe I can send directly from Ruby to PHP without sending to Webdialog ?

      posted in Developers' Forum
      K
      krisjaniszakis
    • Ruby array to hash

      Hi is there a fast way or some ruby libraries how to convert array[] to hash{} ?
      Example of array[]:
      a=[] a << [test1, test2, test3, test4]

      How can I fill in hash{} with entity name and value?

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Webdialog connect to PHP

      Thanks GΓ‘bor and jiminy-billy-bob I combined both scripts and now understand how to do it πŸ˜„

      Does some one know how big(length) array ("v") I can send through ?
      window.location='http://myserver.com/myfile.php?v=' + v;

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Webdialog connect to PHP

      Thanks I thought about it too, but could you pleas post small code example ?

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Webdialog connect to PHP

      It gives me blank page and doesn't transfer
      data
      array to that page 😞

      I will try to look at AJAX thanks.

      posted in Developers' Forum
      K
      krisjaniszakis
    • Webdialog connect to PHP

      Have some one tried to send data from Webdialog to PHP.
      How to do it ?
      I found that post_url could help but it doesnt.

      data << [aa,bb,11,22] dlg = UI::WebDialog.new dlg.post_url("http://localhost/sketch/index.php",data)

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Angle between north and face

      Thanks it was the thing I was looking for πŸ˜„

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Angle between north and face

      @jolran said:

      Hi!

      No response ey? I give it a try.

      Maybe this code is part of a larger piece, otherwise I have a little trouble following your logic.

      Have never used shadow info, and do not have time to look up the methods revolving that.
      Does it really return an angle?

      What is entity ? a face?

      Unless you are going to use those variables later why not just enter:

      tr = Geom::Transformation.rotation(ORIGIN, Z_AXIS, rotation)
      Does not really matter for solving this problem though..

      Try putting a bang to it! Edit in place..

      north_vector.transform! (tr)

      I just wanted to automating angle between north and face.
      With entity I meant "face".

      Here is updated code

      ` north_angle = Sketchup.active_model.shadow_info['NorthAngle']
      flat_normal = entity.normal.clone
      flat_normal.z = 0
      north_vector = Y_AXIS.clone
      north_vector.z = 0
      point = ORIGIN
      up = Z_AXIS
      rotation = north_angle.degrees
      tr = Geom::Transformation.rotation(point,up,rotation)
      north_vector.transform! (tr)
      angle = (north_vector.angle_between(flat_normal)).radians

          if flat_normal.x < 0
             angle = 360-angle
          else
             angle
          end`
      

      And here is Sketchup screenshot with my experiment.

      http://s8.postimg.org/dco1b0rrp/face2.jpg

      For this example script gives that angle between will be 100but not 50, where is the problem ?

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Angle between north and face

      Can some one see:

      1. why if I change north angle result is not changing?

      ` north_angle = Sketchup.active_model.shadow_info['NorthAngle']
      north_vector = Y_AXIS.clone
      north_vector.z = 0
      flat_normal = entity.normal.clone
      flat_normal.z = 0
      point = ORIGIN
      up = Z_AXIS
      rotation = north_angle.degrees
      tr = Geom::Transformation.rotation(point,up,rotation)
      north_vector.transform (tr)
      angle = (flat_normal.angle_between(north_vector)).radians

          if flat_normal.x < 0
             angle = 360-angle
          else
             angle
          end`
      
      posted in Developers' Forum
      K
      krisjaniszakis
    • Angle between north and face

      I have come a cross several posts about angle between but none of them answered my question.

      I want to calculate angle between north and any face in model.
      There should not any restriction if i change north or model.

      #the way how i get north angle north_angle = Sketchup.active_model.shadow_info['NorthAngle']

      Below is algorithm what I want to achieve:

      [pre:2rvuqfdo]x=north_angle
      y=face_angle
      z=angle_between
      if(x>360)
      z=y
      else
      if(x>0)
      if(x+y>360)
      z=x-360+y
      else
      z=x+y
      end
      end
      end[/pre:2rvuqfdo]

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Face xyz

      I was looking for face lower left corner coordinates.
      Thanks TIG it helped me alot, all day I was looking for it πŸ˜„

      posted in Newbie Forum
      K
      krisjaniszakis
    • Face xyz

      Hi,

      How can I export Sketchup::Face xyz coordinates ?
      For Components and Groups I managed to do it.

      Best regards
      Krisjanis

      posted in Newbie Forum sketchup
      K
      krisjaniszakis
    • RE: Entities Edge color apply

      Thanks TIG there can be made changes in my code even more later πŸ˜„

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Entities Edge color apply

      Thanks it helped

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Get parent name and type of entity

      Thanks πŸ˜„

      posted in Developers' Forum
      K
      krisjaniszakis
    • Entities Edge color apply

      Can some one say why this is working: (where 's2' is Sketchup::Edge entity)

      material_name=e2.material
      if mat
      cname=material_name.name
      else
      cname="<Default>"
      end#if
      

      but this is not working:

      material_name=e2.material.name
      

      After this code Ruby returns this error:
      Error: #<NoMethodError: undefined method `name' for nil:NilClass>

      Why i cannot strait forward access material name.

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Get parent name and type of entity

      Also about entities parents.

      Aim is to get parent ID in case the parent Name will be similar to at least 2 entities with:

      parent.id
      

      The code is returns me exact ID and also warning in Ruby console:

      warning; Object#id will be deprecated; use Object#object_id
      

      Is this warning very important or it is optional ?

      posted in Developers' Forum
      K
      krisjaniszakis
    • RE: Get parent name and type of entity

      Thanks, it helped me a lot πŸ˜„
      Basically i used

      if parent.group?
      

      to understand if entities parent is group and

      parent.instances[0].name
      

      to get parents name.

      As i understand as long as I will not be duplicating my group entities I will not get in troubles.

      posted in Developers' Forum
      K
      krisjaniszakis
    • Get parent name and type of entity

      Hi there,

      I have question about, how to get parent name of current enitie.
      It is no problem with ComponentInstance parents but doesnt work with Group parents.

      Parent_name(Sketchup.active_model.entities.parent)

        def self.Parent_name(parent)
            if parent.kind_of? Sketchup;;Model
               pname=Sketchup.active_model.title+" <Model>"
            elsif parent.kind_of? Sketchup;;Group
               pname=parent.name+" <Group>"
            elsif parent.kind_of? Sketchup;;ComponentInstance
               pname=parent.name+" <Component>"
            elsif parent.kind_of? Sketchup;;ComponentDefinition
               pname=parent.name+" <Component>"
            end#if
        end  #Parent_name
      

      My aim is to get Parent Name and Type of exact entity
      P.S. This code snipet is something similar like TIG ComponentReporter++.rb

      posted in Developers' Forum
      K
      krisjaniszakis
    • 1 / 1