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

    Make A Component Using only Ruby code

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 299 Views 2 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.
    • O Offline
      oldnavyflyguy
      last edited by

      Is there any information on creating a component using only Ruby code? So far I have created a 3D model of my component and I basically want to now turn it into a component. I am assuming that the procedure would be to create a component definition and add it to the definition list. Then collect all of the faces and edges of my component and add them to the new componentdefinition.entities collection. I would then like to save the model as a .skp file. Is that it? Is there a better way? I want to use code only from input parameters - no user intervention after inputs. Any advice would be appreciated. I will be happy to share some sample code on this forum when completed. Thanks.

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Hi Steve,

        You seem to have a grip on it for the most part. Instead of creating the geometry before creating the ComponentDefinition, you should create the Definition and then add entities to its Entities collection.

        You can use ComponentDefinition#save_as to save it out to disk.

        
        new_def = Sketchup.active_model.definitions.add("My Component")
        new_def.entities.add_face(...)
        new_def.save_as("C;/My Component.skp")
        model.entities.add_instance(new_def, [0,0,0])
        
        

        Hi

        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