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.
Using Feature Script
occipital scanner mounted to my ipad:
The biggest tip is to keep all functions inside one FS:
Below I've folded all the code to show all the feature script functions in one file. I use 5 functions:
This makes it easy to copy a feature script from one document to another.
When starting a new feature script in a new document:
I create a new feature script in the document and then insert the body of the code into a new feature script. This gives me the latest version of feature script.
So with one feature script, I get all my functions:
The 1st thing I do is read in data and pack an array:
There's over 55,000 points available in the obj file created by the scanner, I parse out over 13,000 points and add them to an array. I pass the array around to different functions using:
sets array in functions that modify the array ie... objData creates the array, objCenter offsets the array:
setVariable(context, 'billysVectors', vectors);
setVariable(context, 'billysArrayCnt', arrayCnt);
read array in every function, every function needs access to the data:
var arrayCnt = getVariable(context, 'billysArrayCnt');
var vectors = getVariable(context, 'billysVectors');
Every function reads the array, some actually re-write the array if I'm making any modifications. For instance, the objCenter routine computes an offset vector and translates the entire dataset by this distance. So after objCenter computes, the data is centered for all remaining functions.
I center the data, occipital does great with orientation, but blows it on location. After centering, I have a function that displays the array. For performance reasons, I limit the display to 500 points:
I create a surface and ask for the points that are a certain distance from that surface:
I create a solid and ask for points inside the volume further reducing the dataset:
From the point cloud, I create some geometry:
So what is this?
It's the buddy peg mount on a motorcycle. I'm replacing the buddy pegs with turns signals. When designing the turn signal, I know what the mounting bracket looks like.
I typically design fenders, shrouds and fender eliminator kits. Usually more organic shapes than a simple bracket. I've also been scanning humans to get body details for medical devices. It's becoming a useful tool.
It's a great way to take organic shapes and bring them into the CAD world.