Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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.

center path finder feature

yarin_amirasyarin_amiras Member Posts: 1 ✭✭
edited January 23 in FeatureScript

Hi I have a problem with my script.
I wrote a script that finds and adds the center path of a given body. So its the center between two given edge paths on the body as well.
However I encountered an error and it didn't work, would appreciate any help! thanks.

The blue body was created using a wiring feature.

Wiring feature:

https://cad.onshape.com/documents/27aba2c60b53c8cebd90a0dd/v/a0887e2f35b6f23864dc1019/e/9c64fc140ab1a8da57c854d0

My script:

https://cad.onshape.com/documents/ebb982f8a9ac390bb5b949e8/w/9b6c4186b0b6a1c246a0a040/e/083ee7edb8854b5f35fd8e40

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,757
    edited January 23

    I know this doesn't help fix your problem, but if you need centrelines, you can use this:

    https://cad.onshape.com/documents/cec835eb44a6b55666a42a85

    Senior Director, Technical Services, EMEA
  • jelte_steur814jelte_steur814 Member Posts: 264 PRO

    I looked at your code shallowly and noticed a few things:

    you have two same for loops after each other. perhaps you could combine those actions into one. You won't even need the first arrays of points because you can just use the poinst to create the center point and store only that in an array. may provide better performance.

    you're making a sketch plane based on edge one. did you use a debug feature to show that sketch? because I'm not sure how it will be oriented.

    more fundamentally, your center points are not necessarily on a plane, so the sketch spline wouldn't be the best way to go. perhaps a 3d spline is a better option, disregarding the sketch (and plane) all together.

    I believe there's something about using variables in a for loop that requires them to be boxed. can't find the documentation quickly. must have been in the self-guided course on featurescript. https://cad.onshape.com/FsDoc/variables.html

Sign In or Register to comment.