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.

FeatureScript: Bounding Box Sketch

john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
edited June 2018 in FeatureScript
Is there a way to create a bounding box sketch on the flat pattern view of sheet metal?

I need it for the stock size call out on the drawings, kind-of a pain in the arse doing it manually.




Tagged:

Best Answers

«1

Answers

  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    I don't know of a pre-existing featurescript that does this, but I would think it's doable. It's just a matter of querying all flatpattern geometry, getting a 3dbox around it, and using the 3dbox parameters to draw a matching sketch. I'm busy at the moment, but I wouldn't be surprised if someone wants to take this and run with it.
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,045 ✭✭✭✭✭
    @john_mcclary
    Does it need to be a sketch? 
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    @mbartlett21 There are a FS "Calculate Bounds" that can create a bounding box of a part, but it don't work with the sheet metal flat part.

    In the sheet metal flat view you only can create sketches
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    @john_mcclary
    Does it need to be a sketch? 
    Yes, I need the sketch to be shown in the drawing view
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    Oh wait, you just sketched it, thought you had a working FS ;p
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    :D Not yet

    I am not sure... but I think we can't create a sketch in the Sheet metal flat view from a FeatureScript
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    Ok, It works...

    In this picture the small rectangle is a sketch in the sheet metal flat view created from a FeatureScript ;-)


    So now we only need to calculate the bounding box to drawn it in the sketch 
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    This is the initial code...

    FeatureScript 847;
    import(path : "onshape/std/geometry.fs", version : "847.0");
    
    annotation { "Feature Type Name" : "SheetMetal BoundingBox" }
    export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            // Define the parameters of the feature type
            annotation { "Name" : "Plano", "Filter" : SheetMetalDefinitionEntityType.FACE && AllowFlattenedGeometry.YES, "MaxNumberOfPicks" : 1 }
            definition.myPlane is Query;
    
        }
        {
            // Define the function's action
            var sketch1 = newSketch(context, id + "sketch1", {
                    "sketchPlane" : definition.myPlane
                });
    
            skRectangle(sketch1, "rectangle1", {
                        "firstCorner" : vector(0, 0) * inch,
                        "secondCorner" : vector(1, 1) * inch
                    });
    
            skSolve(sketch1);
    
        });

    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    It's only creating a small square for me

  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    So now we only need to calculate the bounding box to drawn it in the sketch 
    Yes  :)
    Step 1 - Create a sketch in the sheet metal flat view (DONE)
    Step 2 - Calculate the bounding box (In progress)
    Step 3 - Create the sketck (Pending)
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    One step further 

    Now,
    -Transform the sketch to be in the right position
    -Change to construction geometry

    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,045 ✭✭✭✭✭
    @mbartlett21 There are a FS "Calculate Bounds" that can create a bounding box of a part, but it don't work with the sheet metal flat part.

    In the sheet metal flat view you only can create sketches
    @emagdalenaC2C
    I might actually makemake some improvements to it :) 
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,045 ✭✭✭✭✭
    Oh wait, you just sketched it, thought you had a working FS ;p
    Ps your question is now marked as 'accepted answer' 
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    Oh wait, you just sketched it, thought you had a working FS ;p
    Ps your question is now marked as 'accepted answer' 

    I break everything i touch >_>
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    That's cool, but it doesn't auto calculate the minimum stock size, and also does not allow you to insert the bounding box sketch into a drawing view
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    @mbartlett21 great work

    @john_mcclary calculate the minimum stock size...
    Are you talking about the optimization of the sheet metal

    And, 
    insert the bounding box sketch into a drawing view
    Why you need that?
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    Mostly for design review before release.
    We look over all the details and if I did not show the bounding area of the part as shown below. Then someone asks "will that fit on a sheet?" (58 1/2" x 119") I can point to the "stock size" and say "Yes, We will have ~6 1/4" remaining, but we can only get one on a sheet".

    And if i just add it to the stocksize on the detail callout note without dimensional proof on the part. Then it can slip through the cracks because Onshape will not let me add stocksize automatically to a custom property. So hand typed information needs a double check on paper.


  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    You can edit the FS and add the stocksize properties to the part.

    Also, you can edit the FS and show a message, or don't create the sketch if the size dono't fit on a sheet.

    https://cad.onshape.com/FsDoc/library.html#module-properties.fs
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    @emagdalenaC2C
    Yes you can modify some pre-set properties, but not Custom properties.


  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    You can use TITLE_1, TITLE_2 or TITLE_3 properties
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    Can and should are two different things  :p

    I used to do that trick before I had a company set up; mainly for the use of custom properties. So they are actually labeled to match their content.
    It was a pain in the arse remembering which property "Title3" was really being used for "Mass"

    On top of that I ran out of properties pretty quick what you see there is just the last 5 properties that are attached to every part, I was typing out the stocksize on the sheet manually then. I have it in a property in hopes Onshape will eventually let us FS-edit custom properties as well; at that point I will have the weight, stocksize, etc. all derived directly in the part stuido. (just like I did in SW)
  • brucebartlettbrucebartlett Member, OS Professional, Mentor, User Group Leader Posts: 2,140 PRO
    John what are you doing for weight ATM?  I really want a way to get these this automatically onto the drawing like I used to in SolidWorks as well. 
    Engineer ı Product Designer ı Onshape Consulting Partner
    Twitter: @onshapetricks  & @babart1977   
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    Today I am just manually adding weight to the properties by measuring each part just before release.

    But I have began attempting to make a featurescript to do this automatically by:
    evVolume(context, { "entities" : definition.bodyQuery })

    then reading the material property (I hope I can extract a density from this directly from the material library.... but I doubt it)

    Then I was going to multiply them together and save the result in my custom property.

    But luckily I look ahead and saw I couldn't save to a custom property, so I have up after getting the volume...
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,045 ✭✭✭✭✭
    That's cool, but it doesn't auto calculate the minimum stock size, and also does not allow you to insert the bounding box sketch into a drawing view
    @john_mcclary
    I think it isn't recognising it as a sketch because of it being in a custom feature. :(
    Maybe @lougallo could explain why.

    P.S.
    If you create a sketch then 'use' the edges, it can then be inserted into a drawing.
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,935 PRO
    That's cool, but it doesn't auto calculate the minimum stock size, and also does not allow you to insert the bounding box sketch into a drawing view
    @john_mcclary
    I think it isn't recognising it as a sketch because of it being in a custom feature. :(
    Maybe @lougallo could explain why.

    P.S.
    If you create a sketch then 'use' the edges, it can then be inserted into a drawing.
    True, That would be a reasonable work around.
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,045 ✭✭✭✭✭
    That's cool, but it doesn't auto calculate the minimum stock size, and also does not allow you to insert the bounding box sketch into a drawing view
    @john_mcclary
    I think it isn't recognising it as a sketch because of it being in a custom feature. :(
    Maybe @lougallo could explain why.

    P.S.
    If you create a sketch then 'use' the edges, it can then be inserted into a drawing.
    True, That would be a reasonable work around.
    And if you update the bounding box, it will update your sketch :)
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,045 ✭✭✭✭✭
    @john_mcclary
    @emagdalenaC2C
    I have made an improvement request for sketches created by custom features in the drawing view:
    https://forum.onshape.com/discussion/9655/allow-flat-sketches-from-custom-features-in-drawings
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
Sign In or Register to comment.