sketchucation logo sketchucation
    • Login
    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!
    🚨 Skimp | 25% Off until March 30 Buy Now

    Make A Component Using only Ruby code

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 335 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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better πŸ’—

        Register Login
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement