sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    3d text

    Scheduled Pinned Locked Moved Developers' Forum
    1 Posts 1 Posters 5.6k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jim130
      last edited by

      Hi my name is Jim and I’ve come to the Ruby Sketchup forum before and have been helped so much.
      As I’ve said before I’m new to Ruby and only get to work on my project in the winter so I’m back.
      I’ve tried the Quantum wave function method were you pound your head on the keyboard until the right combination of keys are intersected. But that hasn’t worked. So much for the wave function!

      I’ve printed out and read as much of the Ruby Sketchup API as I can find that applies to 3d text and how to get it to the face of an object but have not progressed very much.
      I’ve created a program to generate a geodesic and am at the point that I need to identify each triangle with a number on its face as well as two numbers at each vertices. After failing to place 3d text on the face of the triangle I went ahead and use 2d text at the vertices but that does not do what I really need.
      I need a 3d text on the surface that I can push pull and have some depth with. As I want to 3d print the form’s for a triangular block for a pizza oven build and each block needs to have its ID embossed into it. Among other things that I want to do with this.
      The way I have approached this is that each triangle is created one at a time in a loop. So that each time the triangle needs to gets the appropriate text placed on its face before going out of the loop and coming back and creating the next triangle.

      I am creating a bounding box with my text inside a bounding box and some were near the center but two major problems appear.

      1. The feedback on the center and corner numbers on the bounding box are not any wear close to wear they should be and

      2. I’ve tried everything I can think of to turn my text variable “m”, the triangle count number into a variable and Ruby won’t allow it.

      I’ll place the code I think you will need so you can see what I am doing and hopefully you can find the errors of my way.

      It’s either that or I’m back to the wave function.

      Thanks again.
      Jim.

      Here is the code.

      polygon_index = pm.add_polygon([pts_xyz_at_n[0] , pts_xyz_at_n[1] , pts_xyz_at_n[2]] )

        #puts" make triangle #{m}"
      
        try = []
        try[0] = pts_xyz_at_n[0]
        try[1] = pts_xyz_at_n[1]
        try[2] = pts_xyz_at_n[2]
      
        entities = mod.active_entities  
      
        group = Sketchup.active_model.entities.add_group   #Add the group to the entities in the model
      
        entities = group.entities             # Get the entities within the group
      
        face = entities.add_face try   # Add a face to within the group
      
        edges = face.edges
      
        status = face.reverse!
      
        normal = face.normal
      
        puts" The normal of triangle face # #{m} is ? #{normal}"
        
        area = face.area
      
        puts "The area of triangle # #{m} is  #{area}"
        
       Sketchup.active_model.entities
      
        model = Sketchup.active_model
      
        entities = mod.active_entities
      
        ################# adds 3d text on at 0,0,0 ######################
      
        group = ent.add_group   # Add the group to the entities in the model
      
        entities = group.entities   # Get the entities within the group
      
        boundingbox = model.bounds
      
        model_bb = model.bounds
      
        ############## adding 3d text to model ###################
        
        success = entities.add_3d_text( "m", TextAlignLeft, "Arial", is_Bold = 0.0 , is_italic = 0.0,letter_height = 0.025, tolerance = 0.0, z = 0.0, is_filled = true, extrusion = 0.0)
      

      puts " success = #{success}"

        first_entity = model.entities[0] 
      
        first_entity_bb = first_entity.bounds
      
        fs_b = first_entity_bb
      
        puts"first_entity = #{fs_b}"
      
        boundingbox.empty?
      
        ptb_1 = boundingbox.center
      
        puts" boundingbox center = #{ptb_1}"
      
        corner_ = boundingbox.corner(0)
      
        puts" boundingbox corner(0) = #{corner_}"
      
        group.to_component
        
        m  =  m  +  1                    #### incrementing  m
      

      Here is the output.

      Points and side length for triangle # 9

      Point, # 1 is [3, 3] and has the co ordinance of [0.13238464691208032, 0.2812274564551052, 0.9504658978615464]

      Point, # 2 is [4, 2] and has the co ordinance of [6.005807236859207e-17, 0.19473874066922284, 0.9808551487771093]

      The length of side 1 of triangle # 9 is between point [3, 3], and point [4, 2], for a length of 0.16102639307745903

      Point, # 2 is [4, 2] and has the co ordinance of [6.005807236859207e-17, 0.19473874066922284, 0.9808551487771093]

      Point, # 3 is [4, 4] and has the co ordinance of [5.719967031754901e-17, 0.3568220897730899, 0.9341723589627158]

      The length of side 2 of triangle # 9 is between point [4, 2], and point [4, 4], for a length of 0.16867215218162387

      Point, # 3 is [4, 4] and has the co ordinance of [5.719967031754901e-17, 0.3568220897730899, 0.9341723589627158]

      Point, # 1 is [3, 3] and has the co ordinance of [0.13238464691208032, 0.2812274564551052, 0.9504658978615464]

      The length of side 3 of triangle # 9 is between point [4, 4], and point [3, 3], for a length of 0.1533157615327414

      333 The normal of triangle face # 9 is ? (0.039739, 0.276548, 0.960178)

      The area of triangle # 9 is 0.01117362776006554

      The bounding box output stuff.

      success = true

      first_entity = #Geom::BoundingBox:0x00000248a3959ac8

      boundingbox center = (0", 0", 0.079675")

      boundingbox corner(0) (-0.850651", -0.850651", -0.850651")

      number of triangles = 10

      Frequency = 8

      Radius = 1.0

      I think I can get the text to the face if I can just get the bounding box right and its cooridnates.


      screen shot

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement