sketchucation logo sketchucation
    • Login
    1. Home
    2. cjthompson
    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!
    πŸ”Œ Easy Offset | Offset selected faces in SketchUp in positive and negative offsets. Download
    C
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 19
    • Posts 151
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Way to lock component definition

      @thomthom said:

      @cjthompson said:

      I thought of that, but there are still plugins that can modify a definition without having to go into edit mode.

      Have you tried locking all the entities inside the definition?

      How do you do that?

      posted in Developers' Forum
      C
      cjthompson
    • RE: Script to Delete Hidden Objects?

      Why not make it select all hidden entities? That way, he can see what is hidden, and then just press the delete key.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Way to lock component definition

      @cjthompson said:

      assuming the plugin will always be installed?

      @thomthom said:

      I guess you can monitor the active entity path and close the instance when the user tries to open it..?

      I thought of that, but there are still plugins that can modify a definition without having to go into edit mode.

      Another idea I had was to save the component to a temp file, and then reload it, but that might be really slow. Which leads me to another question: Is there any way to load a component from a file twice? Whenever I've tried it, it doesn't create a new definition, it just ignores the command.

      posted in Developers' Forum
      C
      cjthompson
    • Way to lock component definition

      I am trying to find a way to lock a definition of a component, so that the end user can move an instance of it, but not modify the contents.

      Is this possible, assuming the plugin will always be installed?

      posted in Developers' Forum
      C
      cjthompson
    • RE: Geom::Transformation.new( Vector3d )

      @tig said:

      @thomthom said:

      .move! is good when you want to move without affecting the undo-stack.

      BUT since move! takes a transformation made in the form .new(pt) and that is no different from .new(vec) you can't move to an absolute point only a point relative to the transformation origin UNLESS you do some work beforehand to work out a .new(point) that's equivalent to an 'absolute' move ? πŸ˜•
      You need to find the origin relative to the ORIGIN ? and go from there ? πŸ˜’

      Except that .move! is essentially the same as .transformation= (as far as I understand), so all you have to do is provide an absolute point.

      EDIT: that might also be the source of Martin's confusion.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Geom::Transformation.new( Vector3d )

      I think the problem is that Transformation.new(Point3d) is the same transformation as Transformation.new(Vector3d), not the other way around. (if that makes any sense)

      try this(assuming inst is a component instance):

      
      inst.transformation = Geom;;Transformation.new([10,0,0]) #places it at 10,0,0
      inst.transform!(Geom;;Transformation.new(Geom;;Vector3d.new(20,20,0)))
      inst.transformation.origin # => (30,20,0), like it should
      
      

      then this:

      
      inst.transformation = Geom;;Transformation.new([10,0,0]) #places it at 10,0,0
      inst.transform!(Geom;;Transformation.new(Geom;;Point3d.new(20,20,0)))
      inst.transformation.origin # => (30,20,0), not (20,20,0)
      
      
      posted in Developers' Forum
      C
      cjthompson
    • RE: [code] Timer class

      Just a very small suggestion: instead of having

      t = Timer.new( 1.0/fps, tt )
      

      you might want to put:

      t = Timer.new( 1/fps.to_f, tt )
      

      That way, people experimenting with the code can easily change the numbers, without having to make sure that it's a decimal.

      EDIT: Although, now that I think of it, they would only change the fps, not the 1. 😳

      posted in Developers' Forum
      C
      cjthompson
    • RE: Ruby right write

      @chrisglasier said:

      
      > @dlg.add_action_callback("save_json") { |d, a|
      > 			p = a.split(";")
      > 			subDir = "nset/Sketchup/"
      > 			file = File.join(File.dirname(__FILE__), subDir, p[0])
      > 			f = File.open(file, 'w')
      > 			f.puts p[1].to_s
      > 			f.close
      > 		}
      > 
      

      I think the problem is

      f.puts p[1].to_s
      

      Try using

      f.write p[1].to_s
      
      posted in Developers' Forum
      C
      cjthompson
    • Difference between 4 % 2 and 4 %2

      Does anyone know why 4 %(space)2 works, but 4 %(no space)2 raises a syntax error (if it's in a file)?

      Also, why does 2 -1 work, and 2.to_f - 1 works, but 2.to_f -1 doesn't?

      posted in Developers' Forum
      C
      cjthompson
    • RE: "Tell me what's goin' on. I ain't got a clue!"

      this is a bit off topic, but I was just curious: how would you handle a rectangle that has a normal of (1,1,-1) or something similar?

      posted in Developers' Forum
      C
      cjthompson
    • RE: Non-model geometry

      I noticed that the API documentation for view.draw_(lines,points,etc...) mentions that it is usually implemented inside the draw method.

      Is there any other way you can implement them?

      posted in Developers' Forum
      C
      cjthompson
    • RE: New API doc - typos and questions

      I think I found what your problem is.

      This works:

      
      mesh = Geom;;PolygonMesh.new
      mesh.add_polygon(Geom;;Point3d.new(0,0,0),Geom;;Point3d.new(1,0,0),Geom;;Point3d.new(1,1,0),Geom;;Point3d.new(0,1,0))
      Sketchup.active_model.entities.add_faces_from_mesh(mesh)
      
      

      This doesn't:

      
      mesh = Geom;;PolygonMesh.new
      mesh.add_polygon([0,0,0],[1,0,0],[1,1,0],[0,1,0])
      Sketchup.active_model.entities.add_faces_from_mesh(mesh)
      
      

      EDIT:
      You can put the arrays inside of another array to get it to work:

      
      mesh = Geom;;PolygonMesh.new
      mesh.add_polygon([[0,0,0],[1,0,0],[1,1,0],[0,1,0]]) #this works
      Sketchup.active_model.entities.add_faces_from_mesh(mesh)
      
      
      posted in Developers' Forum
      C
      cjthompson
    • RE: New API doc - typos and questions

      now I see why it doesn't work with arrays:

      
      mesh = Geom;;PolygonMesh.new
      mesh.add_point([0,0,0])
      mesh.add_point([1,0,0])
      mesh.add_point([1,1,0])
      mesh.add_point([0,1,0])
      mesh.add_polygon([1,2,3,4])
      Sketchup.active_model.entities.add_faces_from_mesh(mesh)
      
      

      you can use an array to index the points directly (for some reason, starting at 1)!

      Can you test whether this is faster than point_at?

      posted in Developers' Forum
      C
      cjthompson
    • RE: New API doc - typos and questions

      @thomthom said:

      PolygonMesh.add_polygon
      http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/polygonmesh.html#add_polygon

      I can't seem to add points like the example does.

      Instead, I must first add each point using PolygonMesh.add_point and then provide PolygonMesh.add_polygon with index values that refers to the points.

      That's weird. It works just fine for me.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Angle = vector1.angle_between vector2

      Have you tried vector1.angle_between(vector2.reverse)?

      posted in Developers' Forum
      C
      cjthompson
    • RE: Entity.visible? vs entity.hidden?

      @al hart said:

      entity.is_in_current_view - is_visible? and also is visible in current camera view
      entity.is_obstructed - is visible? but is behind something else which is not transparent.

      I think I would like at least these two to be part of the view object, and pass in an entity, not on the entity itself.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Adding observers to a group of entities

      Here is an abridged version:

      
      class EntityObserver
      	def onChangeEntity(entity)
      		puts entity.to_s + " changed"
      	end
      end
      
      $entityObserver = EntityObserver.new
      
      def addObserver
      	Sketchup.active_model.selection.each{|entity| entity.add_observer($entityObserver)}
      end
      def removeObserver
      	Sketchup.active_model.selection.each{|entity| entity.remove_observer($entityObserver)}
      end
      

      If you have one entity selected, it adds and removes fine, but if you have more than one entity selected, it only removes the first entity in the selection.

      posted in Developers' Forum
      C
      cjthompson
    • Adding observers to a group of entities

      Has anyone had trouble adding observers to a group of entities?

      It seems to add the observers just fine, but when I try to remove them, it only is able to remove the first entity in the group. Also, if I try remove, then add any observers, it never adds the observers.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Model.active_path uses global coordinates?

      the way I solve this problem is with entities.transform_entities(entities.to_a,model.edit_transform.inverse), which effectively reset the definition.

      Then, when you are done editing, just do the same thing without the .inverse

      posted in Developers' Forum
      C
      cjthompson
    • Layout to dxf or dwg

      Is there any way to convert a layout drawing to a 2d dxf or dwg?

      posted in LayOut Discussions layout
      C
      cjthompson
    • 1 / 1