Make A Component Using only Ruby code
-
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.
-
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_asto 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])
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 LoginAdvertisement