Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
How can I make a composite part of all of the bodies I create in a feature?
monroe_weber_shirk
Member Posts: 103 EDU
I'm writing a feature script to create a ruler or a scale that includes tick marks and numbers. I want to combine all of the ticks and numbers into a single composite part at the end of the feature script.
I first tried
opCreateCompositePart(context, id, { "bodies" : qAllModifiableSolidBodies(), "closed" : false });
but that put all of the bodies in the part studio into the composite and I only want the parts created in this feature to be in the composite.
I tried creating an array of all of the bodies as I create them.
tickbodies[i] = qCreatedBy(currentID + "tick", EntityType.BODY);
and then used
opCreateCompositePart(context, id, {and then used
"bodies" : tickbodies,
"closed" : true
});
That fails because "bodies" is not expecting an array.
What is the elegant way of putting all of these ticks and numbers into a composite part?
0
Best Answer
-
Just use qCreatedBy(id) for all bodies created in the current feature.
Senior Director, Technical Services, EMEA1
Answers
-
presumably you creating tick bodies in a loop? if so then before loop you need to define an empty array:var tickBodies=[];//then if the loop you create new body with operation id depending on some "i" and you append the query of that body to the array.for (var i=0, i<N, i+=1; ){//here you apply some operations creating new body with body creation operation id: id+("tickBody"~i)//here you appending array with operation idtickBodies = append(tickBodies, qCreatedBy(id+("tickBody"~i), EntityType.BODY));}//and finally outside of the loop you turn array of queries into the query for multiple bodies wich you can pass to opCreateCompositePart()tickBodies = qUnion(tickBodies);
0 -
Just use qCreatedBy(id) for all bodies created in the current feature.
Senior Director, Technical Services, EMEA1 -
Elegant! Thank you!
0


