Export the geometry of a drawing

fredrik_tärnell
fredrik_tärnell Member Posts: 29 ✭✭
Hi,

Found a few thread discussing wireframe and on in particular that created a FS to do that 
https://forum.onshape.com/discussion/5437/wires-from-edges-suggestions

It does not seem to work for more complex parts/objects.

What I really want it to "produce and object" like what gets during a drawing creation. But as an object I can export. Would that be possible? But I guess I would need access to the actual geometry rather than the exported faces, right?  

Answers

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    edited October 2019
    This code will do it. Create a Feature Studio, paste this in and press commit. The feature will then be available in your Part Studio.

    annotation { "Feature Type Name" : "Wireframe Edges" }
    export const wireframe = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Parts", "Filter" : EntityType.BODY }
            definition.parts is Query;
    
            annotation { "Name" : "Delete parts" }
            definition.delete is boolean;
        }
        {
            var edges = qOwnedByBody(definition.parts, EntityType.EDGE);
    
            for (var i = 0; i < size(evaluateQuery(context, edges)); i += 1)
            {
                opExtractWires(context, id + ("opExtractWires" ~ i), {
                            "edges" : qNthElement(edges, i) });
            }
    
            if (definition.delete)
            {
                opDeleteBodies(context, id + "deleteBodies", {
                            "entities" : definition.parts });
            }
        });
    
    You can then export the wireframe geometry using STEP by right-clicking the Part Studio tab at the bottom and selecting Export.

    Senior Director, Technical Services, EMEA