Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete worksurface

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
759 Views, 8 Replies

Delete worksurface

Does anyone know how to delete a work surface.  These work surfaces were imported from an iges file which contains thousands of work surfaces.  They are not associated with a part feature which can be deleted.  I've developed a routine to sort through these and identify unwanted work surfaces based on their positions.  The best I've been able to come up with is to make them invisible, but I'd really like to delete them completely to clean up the file.  I did try to loop through and delete any surfacebody objects associated with the worksurface but that failed.  Any help would be appreciated!

8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

have you tried

oWorkSurface.SurfaceBodies(1).Delete

Message 3 of 9
Anonymous
in reply to: Anonymous

Yes I have, but the method fails.

Message 4 of 9
jdkriek
in reply to: Anonymous

Can you post your code thus far, we'll maybe be able to pinpoint while the method is failing.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 9
Anonymous
in reply to: Anonymous

I was really hoping to hear from Autodesk on whether or not this was possible...

Message 6 of 9
ekinsb
in reply to: Anonymous

Can you post a file that contains a few of these surfaces so I can be sure I'm testing the correct thing?


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 7 of 9
Anonymous
in reply to: ekinsb

Hi Brian,

 

I looked at this from another angle and found that the worksurfaces are being controled by nonparametricbasefeatures.  Once I figured this out I was able to delete the feature and have the worksurface disappear. 

 

What I'd like to accomplish now is to further simplify the part by creating a single worksurface that represents the floor and removing any other surfaces which are touching it and also parallel to it.  The boundary for the floor work surface could be the borders of the rangebox for the entire part.

 

How can I determine if a face is parallel and touching another face within a tollerance and change the shape of a worksurface as you can with the "Extend" command in the user interface?

 

 

Message 8 of 9
ekinsb
in reply to: Anonymous

Hi Robert,

 

I think what you want to do is possible, but it's going to involve diving a bit deeper into the API.  I'm not sure I fully understand what you want to do but I'm guessing you want to find all of the faces that lie on a single plane and replace them with a larger plane that encompasses all of them.  From any Face object you can get the underlying geometry using the Geometry property.  The faces in your sample were all planes.  From a Plane object you can get its normal and a point on the plane.  I use that in the sample below to find planes are the coincident within some tolerance to a select face.  I'm not sure how the extents of the new plane are determined (encompass the found planes or an intersection with other planes), but there will be more work to compute that. Rather than extend any of the existing planes I would build a new one.

 

Public Sub FindCoincidentPlanes()
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument
    
    ' Have the user select a face.
    Dim selFace As Face
    Set selFace = ThisApplication.CommandManager.Pick(kPartFacePlanarFilter, _
                                                      "Select a face.")
    
    ' Get the plane geometry from the face.
    Dim selPlane As Plane
    Set selPlane = selFace.Geometry
    
    Dim coincFaces As FaceCollection
    Set coincFaces = ThisApplication.TransientObjects.CreateFaceCollection
    
    ' Iterate through all of the work surfaces and their faces
    ' looking for coincident faces.
    Dim workSurf As WorkSurface
    For Each workSurf In partDoc.ComponentDefinition.WorkSurfaces
        Dim checkFace As Face
        For Each checkFace In workSurf.SurfaceBodies.Item(1).Faces
            ' Make sure this face is a plane.
            If checkFace.SurfaceType = kPlaneSurface Then
                Dim checkPlane As Plane
                Set checkPlane = checkFace.Geometry
                
                ' Check to see if the normals fo this face and selected face are parallel.
                Dim pi As Double
                pi = Atn(1) * 4
                If selPlane.Normal.IsParallelTo(checkPlane.Normal, 10 * (pi / 180)) Then
                    ' Check to see if they're coincident.
                    Dim dist As Double
                    dist = ThisApplication.MeasureTools.GetMinimumDistance(checkPlane, _
                                                                    selPlane.RootPoint)
                    
                    If dist < 10 Then
                        ' Face is coincident, so add it to the collection.
                        Call coincFaces.Add(checkFace)
                    End If
                End If
            End If
        Next
    Next
    
    ' Check to see if there were coincident faces and select all of them.
    If coincFaces.Count > 0 Then
        Call partDoc.SelectSet.SelectMultiple(coincFaces)
    End If
End Sub

 

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 9 of 9
Anonymous
in reply to: ekinsb

Thanks Brian.  Youve given me some great information and a big head start on this project!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report