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.
Defining variables and prompts
susan_moss
Member Posts: 3 EDU
I am just starting to explore FeatureScript and the documentation - while decent, is insufficient.
My background - I have been coding since the days of DOS. I can code in BASIC (geez, my age shows), C++, VisualBASIC, VisualLISP, AutoLISP, JAVA, html, and a few other extremely esoteric languages that are specific to their own little software programs...4GL, anyone? So, I am not afraid to tinker and I don't mind writing code.
I always start by writing down an outline of what I want the code to do and use it as my guide.
So, I want to create a sketch. I start by drawing a construction line. I want to assign a variable for the length of the construction line. I then want to place two lines offset parallel to the construction line at a distance from the construction line. I would like to prompt the user for the length of the construction line and for the distance from the construction line to the offset line. I then would like to be able to add a linear dimension to the sketch designating the length of construction line.
I see the sketch tool - no problem.
I see the line tool - no problem. But how do I define it as a construction line?
I see the Length parameter. I am assuming this prompts the user for the length value. In the code I can change the name, but do I also need to modify the definition.myLength to use definition.myVar?
I don't see any tool on how to add a dimension.
Thanks for any enlightenment.
Elise Moss
My background - I have been coding since the days of DOS. I can code in BASIC (geez, my age shows), C++, VisualBASIC, VisualLISP, AutoLISP, JAVA, html, and a few other extremely esoteric languages that are specific to their own little software programs...4GL, anyone? So, I am not afraid to tinker and I don't mind writing code.
I always start by writing down an outline of what I want the code to do and use it as my guide.
So, I want to create a sketch. I start by drawing a construction line. I want to assign a variable for the length of the construction line. I then want to place two lines offset parallel to the construction line at a distance from the construction line. I would like to prompt the user for the length of the construction line and for the distance from the construction line to the offset line. I then would like to be able to add a linear dimension to the sketch designating the length of construction line.
I see the sketch tool - no problem.
I see the line tool - no problem. But how do I define it as a construction line?
I see the Length parameter. I am assuming this prompts the user for the length value. In the code I can change the name, but do I also need to modify the definition.myLength to use definition.myVar?
I don't see any tool on how to add a dimension.
Thanks for any enlightenment.
Elise Moss
Tagged:
0
Answers
It sounds like you're coming to grips with some of the core concepts of FeatureScript. One helpful resource is the tutorials, found here. They introduce a lot of useful, generalizable patterns.
I want to place the dimensions, so I have the option of modifying them later manually.
I did skim through the tutorials, but couldn't find an example of auto-placing the dimension.
You can have a length parameter that controls the sketch dimension, as done with the width parameter in the slot tutorial. When you have such a parameter, you can use the value to place sketch entities (the easier way), or use it to drive a dimension.