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.
extending Neil Cooke 's port feature won't work
tonvis
Member Posts: 41 ✭✭
https://cad.onshape.com/documents/537978ffd6db628ae304a014/w/c4df816f6f58ef48a64f3b91/e/2faa916019fd524dd61d27ac
Can someone please helpme out. Selecting other enums will not work , only the last in a row gets selected.
I tryed everything but I can't find any mistake.
Part of code:
---------------------
Many thanks for your help.
tonvis
Can someone please helpme out. Selecting other enums will not work , only the last in a row gets selected.
I tryed everything but I can't find any mistake.
Part of code:
---------------------
annotation { "Feature Type Name" : "Ports_generator",
"Feature Name Template" : "#screwtype Screw",
"Editing Logic Function" : "editPortLogic" }
//export const portFeature = defineFeature(function(context is Context, id is Id, definition is map)
export const Ports_generator = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Screw" }
definition.screw is ScrewType;
// no way to get this "SAE " enum done !, BSP dimensions will always be selected
if (definition.screw == ScrewType.SAE)
{
annotation { "Name" : "SAE" }
definition.portSize is PortSize;
}
if (definition.screw == ScrewType.BSP)
{
annotation { "Name" : "BSP " }
definition.bspportSize is BSPPortSize;
}
annotation { "Name" : "Points", "Filter" : EntityType.VERTEX }
definition.points is Query;
annotation { "Name" : "Depth" }
isLength(definition.depth, DEPTH_BOUNDS);
}
Many thanks for your help.
tonvis
0
Best Answer
-
MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭Can you try this code.
I added some if statements in the body of your codeFeatureScript 975; import(path : "onshape/std/geometry.fs", version : "975.0"); ... annotation { "Feature Type Name" : "Ports_generator", "Feature Name Template" : "#screwtype Screw", "Editing Logic Function" : "editPortLogic" } export const Ports_generator = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Screw" } definition.screw is ScrewType; if (definition.screw == ScrewType.SAE) { annotation { "Name" : "SAE" } definition.portSize is PortSize; } if (definition.screw == ScrewType.BSP) { annotation { "Name" : "BSP " } definition.bspportSize is BSPPortSize; } annotation { "Name" : "Points", "Filter" : EntityType.VERTEX } definition.points is Query; annotation { "Name" : "Depth" } isLength(definition.depth, DEPTH_BOUNDS); } { //--------------------------------------- Body ----- var ports; var depth = definition.depth; // ---------------------------------------------------------------------- SAE UNF ------------------------------------------------------------------- //here the vector points for each port are added to an array depending on size chosen if(definition.screw == ScrewType.SAE){ if (definition.portSize == PortSize.fiveSixteen) { ports = [vector(0, 0) * inch, vector(-depth, 0 * inch), vector(-depth + .019 * inch, -.031 * inch), vector(-.631, -.031) * inch, vector(-.53, -.132) * inch, vector(-.167, -.132) * inch, vector(-.136, -.163) * inch, vector(-.062, -.179) * inch, vector(-.062, -.336) * inch, vector(0, -.336) * inch, vector(0, 0) * inch]; } if (definition.portSize == PortSize.threeEights) { ports = [vector(0, 0) * inch, vector(-depth, 0 * inch), vector(-depth + .038 * inch, -.063 * inch), vector(-.629, -.063) * inch, vector(-.53, -.162) * inch, vector(-.169, -.162) * inch, vector(-.136, -.195) * inch, vector(-.062, -.211) * inch, vector(-.062, -.375) * inch, vector(0, -.375) * inch, vector(0, 0) * inch]; } if (definition.portSize == PortSize.sevenSixteen) { ports = [vector(0, 0) * inch, vector(-depth, 0 * inch), vector(-depth + .052 * inch, -.086 * inch), vector(-.663, -.086) * inch, vector(-.547, -.202) * inch, vector(-.176, -.202) * inch, vector(-.155, -.224) * inch, vector(-.062, -.243) * inch, vector(-.062, -.414) * inch, vector(0, -.414) * inch, vector(0, 0) * inch]; } if (definition.portSize == PortSize.half) { ports = [vector(0, 0) * inch, vector(-depth, 0 * inch), vector(-depth + .07 * inch, -.117 * inch), vector(-.71, -.117) * inch, vector(-.607, -.22) * inch, vector(-.188, -.22) * inch, vector(-.153, -.255) * inch, vector(-.062, -.275) * inch, vector(-.062, -.453) * inch, vector(0, -.453) * inch, vector(0, 0) * inch]; } if (definition.portSize == PortSize.nineSixteen) { ports = [vector(0, 0) * inch, vector(-depth, 0 * inch), vector(-depth + .089 * inch, -.149 * inch), vector(-.773, -.149) * inch, vector(-.671, -.251) * inch, vector(-.195, -.251) * inch, vector(-.159, -.287) * inch, vector(-.062, -.308) * inch, vector(-.062, -.485) * inch, vector(0, -.485) * inch, vector(0, 0) * inch]; } if (definition.portSize == PortSize.threeFour) { ports = [vector(0, 0) * inch, vector(-depth, 0 * inch), vector(-depth + .117 * inch, -.196 * inch), vector(-.928, -.196) * inch, vector(-.782, -.341) * inch, vector(-.237, -.341) * inch, vector(-.194, -.384) * inch, vector(-.094, -.406) * inch, vector(-.094, -.594) * inch, vector(0, -.594) * inch, vector(0, 0) * inch]; } if (definition.portSize == PortSize.sevenEights) { ports = [vector(0, 0) * inch, vector(-depth, 0 * inch), vector(-depth + .145 * inch, -.242 * inch), vector(-1.032, -.242) * inch, vector(-.875, -.399) * inch, vector(-.245, -.399) * inch, vector(-.194, -.45) * inch, vector(-.094, -.471) * inch, vector(-.094, -.672) * inch, vector(0, -.672) * inch, vector(0, 0) * inch]; } if (definition.portSize == PortSize.oneSixteen) { ports = [vector(0, 0) * inch, vector(-depth, 0 * inch), vector(-depth + .183 * inch, -.304 * inch), vector(-1.22, -.304) * inch, // R6 vector(-1, -.525) * inch, // R5 vector(-.246, -.525) * inch, // R4 vector(-.224, -.546) * inch, // R3 vector(-.094, -.574) * inch, // R2 vector(-.094, -.813) * inch, // R1 vector(0, -.813) * inch, //originn vector(0, 0) * inch]; } } // --------------------------------------------------------- BSP ---British Pipe Thread else if(definition.screw == ScrewType.BSP){ if (definition.bspportSize == BSPPortSize.oneEight) { ports = [vector(0, 0) * mm, vector(-depth, 0 * mm), vector(-depth + 2 * mm, -1.5 / 2 * mm), vector(-15, -1.5 / 2) * mm, //r6 vector(-14, -9.3 / 2) * mm, //r4 vector(-12, -9.5 / 2) * mm, //r3 vector(-3, -9.7 / 2) * mm, //r2 vector(-2, -14 / 2) * mm, //r1 vector(0, -14 / 2) * mm, //r1 vector(0, 0) * mm]; } } ...
5
Answers
while your feature studio has this
You are right ,this is my fault. Due to many trials I made a typing error there .But correcting the feature according your comment does not help to solve the problem. There is something else going wrong. I am looking in all kind of feature scripts for over a week, but can't find the solution.
Selection another enum will not activated , and there is no error message.
Can you please give it another eye.
https://cad.onshape.com/documents/537978ffd6db628ae304a014/w/c4df816f6f58ef48a64f3b91/e/de74c96ae6e157189c9be65d
Best regards
tonvis
I added some if statements in the body of your code
IR for AS/NZS 1100