sketchucation logo sketchucation
    • Login
    1. Home
    2. ado130
    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!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
    A
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 24
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: How to cut from object

      TIG, please, can you help me with that.

      posted in Developers' Forum
      A
      ado130
    • RE: How to cut from object

      About groups, I'm not sure, if I'm doing it right.
      Rectangel blocks:

      
      group = Sketchup.active_model.entities.add_group 
      entities = group.entities
      ptA = [x[0+i*8], y[0+i*8], z[0+i*8]].map(&;to_f)
      ...
      entities.add_line(ptA, ptB)
      ...
      bottom = entities.add_face(ptA, ptB, ptC, ptD)
      ...
      bottom.material = blockMaterial[i]
      ...
      bottom.back_material = blockMaterial[i]
      ...
      
      

      Similarly cylinders (just using entities.add_circle).
      Is it a right way?

      Now for make a drill (not a notch), I need to find a face, so I'm trying sth like this

      	model = Sketchup.active_model 
      	entities = model.entities
      
      	face = nil
      	entities.grep( Sketchup;;Group ).each{|e|
      	  puts "Group #{e.name.empty? ? e.definition.name.inspect ; e.name.inspect};"
      	  faces = e.definition.entities.grep( Sketchup;;Face )
      	  if faces.empty?
      		puts "  +-- No faces in group!"
      	  else
      		for f in faces
      		  if f.classify_point(center) == Sketchup;;Face;;PointInside then
      		   face = f
      		  end
      		end
      	  end
      	}
      

      It works - it finds right face, but after, when I execute code from here http://sketchucation.com/forums/viewtopic.php?t=19556, the result is, that the block disappear and stay just a circle edge.

      When I add group.explode at the end of block for making rectangles and cylinders works fine this:

      	entities.each { |entity| 								# Get all entities
      		if entity.typename == "Face" then					# Get all faces from entities
      			result = entity.classify_point(center)
      			if result == Sketchup;;Face;;PointInside then	# Get our face 
      				face = entity
      			end		
      		end
      	}
      

      If I think properly, gourp.explore deletes that group, but I need it for use in intersect_with.
      So, is this process right: delete that group via group.explode (for making drills) and before making notch, create new group of block and temporary cylinder?

      I learn from this https://www.sketchup.com/intl/en/developer/docs/ and forum.

      Thanks

      Edit:

      	baseGroup = nil
      	Sketchup.active_model.entities.each{|g|
      		next unless g.is_a?(Sketchup;;Group)
      		g.entities.each{|f|
      			next unless f.is_a?(Sketchup;;Face)
      			next if f.classify_point(notchPoint) == Sketchup;;Face;;PointInside	
      			baseGroup = g
      		}	
      	}	
      	
              baseTrans = baseGroup.transformation
      	
              cutGroup=entities.add_group
              cutGroupEntities=cutGroup.entities	
      	dir = Geom;;Vector3d.new(-1,0,0)
      	cutCircle = cutGroupEntities.add_circle(notchPoint, dir, cylinderRadius[0])
      	cutFace   = cutGroupEntities.add_face cutCircle 
      	cutNormal = cutFace.normal
      	cutFace.reverse!
      	cutFace.pushpull cylinderHeight[0]	
      	cutTrans = cutGroup.transformation	
      	
      	cutGroupEntities.intersect_with(false, cutTrans, baseGroup, baseTrans , true, baseGroup)
      
      	cutGroup.explode
      

      In baseGroup variable I need to find a group where I'll do a notch - and yeah, it does not work at well (now I have just 1 block, so just 1 group, but later I'll have a lot of blocks/groups).
      Then I do a temporary cylinders and trying execute intersect_with, but I'm not sure if is it correct. Can you help me?

      Thanks a lot.

      posted in Developers' Forum
      A
      ado130
    • RE: How to cut from object

      Ou, sorry about that.
      Tig, you are right, now I'm using Sketchup 2016, just a trial version, but soon I'll use Sketchup 8, is it still possible?
      For better imagination, for Ex. I've this

      http://i.imgur.com/G46UlIJ.png

      and I need sth like this

      http://i.imgur.com/hafBjP7.png

      of course without edges.
      So, now I have a object and position(center) of "imagination" drill - there's no face, but the drill will do "notch".
      Can you help me?
      Maybe write a example code or a little tutorial how to do it and I'll try it myself.

      Thanks very much.

      .. sorry for my english

      Edit: I just installed SU8 and I'm not sure, but is it possible there? It looks very different, not so much in design but in functions that I can use.

      posted in Developers' Forum
      A
      ado130
    • How to cut from object

      Hi, I'm new in Ruby and sketch, so I learnt to do a couple of simple objects (blocks, cylinders), then I tried do a drill - it works, but I do not know how do a cut.
      I can do a hole - drill if the center is in the object, but I have no idea, how do a cut, when the center is out of the object. I know just x y z position, radius and depth of the drill.

      Thanks for any help.

      posted in Developers' Forum
      A
      ado130
    • 1 / 1