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!
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
Can you post a file that contains a few of these surfaces so I can be sure I'm testing the correct thing?
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?
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
Can't find what you're looking for? Ask the community or share your knowledge.