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.

import command improvement

traveler_hauptmantraveler_hauptman Member, OS Professional, Mentor, Developers Posts: 419 PRO
Imports are a bit inscrutable at the moment. It would be nice if the 'import' button commented the lines it inserts with descriptive info
import(
path : "3bf95367da7496dc5f19bf6c/d1068c2a6e0fdf68c9cba6a6/aa51840ef58770354c6dd517",
 version : "6cdb68bb3b66a2d24bc61ff9"); // User/Team: Bubba DocName: Super Features



Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    Totally agree. We also want to make sure the actual import and the human-readable text don't go out of sync, so we have something a little fancier planned for this. Thanks for the feedback, and sit tight for the fix!

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
    edited May 2016
    Here's a csv parser Iyla wrote:

    function parseVertex(s is string) // Returns a unitless 3D Vector or undefined
    {
        const regexp = "v\\s+" ~ REGEX_NUMBER_CAPTURE ~
            "\\s+" ~ REGEX_NUMBER_CAPTURE ~
            "\\s+" ~ REGEX_NUMBER_CAPTURE ~ "\\s*";
        const matches = match(s, regexp);
        if (!matches.hasMatch)
            return undefined;
        var result = makeArray(3);
        for (var i in [0, 1, 2])
            result[i] = stringToNumber(matches.captures[i + 1]);
        return vector(result);
    }
    The input file looks like this:
    # Generated.
    v 0.0060 0.4554 0.0050
    vn 0.41 -0.49 -0.77
    v 0.0060 0.4535 0.0060
    vn 0.40 -0.51 -0.76
    v 0.0020 0.4554 0.0033

    and returns x,y,z; I guard this function and only pass in strings beginning with "v ".

    You can re-purpose it to parse your file.

    -Remember to add "csv" to the end of your uploaded file name.
    -Don't try and rename file in OS, that stopped working a couple of weeks ago (I think it's still broken).
    -watch for carriage returns at the end of file, that broke my parsing routine.


Sign In or Register to comment.