neophyte Posted June 30, 2009 Posted June 30, 2009 Hi I want to know how to erase a part of a drawing (by VBA). The zone to erase will be alway the same on each drawing I want to do by a windows selection (point1: 0,0,0 point2: 10,15,0) I try by using acSelectionSetWindows but that does'nt work Thanks ps : Here what I tested. I know there are several lines to put at the garbage, but I keep all the lines of codes who were tested Private Sub test() Dim ObjSelection As AcadSelectionSet Dim ObjetOut As AcadEntity Dim Point1(0 To 2) As Double Dim Point2(0 To 2) As Double Dim Point3(0 To 5) As Double 'Data Point1(0) = 0# Point1(1) = 0# Point1(2) = 0# Point2(0) = 10# Point2(1) = 15# Point2(2) = 0# Point3(0) = 0# Point3(1) = 0# Point3(2) = 0# Point3(3) = 10# Point3(4) = 15# Point3(5) = 0# On Error Resume Next 'set ObjSelection = ThisDrawing.PaperSpace.Item '. SelectionSets.Item.SelectByPolygon(acSelectionSetWindowPolygon, Point3) ObjSelection.Clear Set ObjetOut = ObjSelection.Select acSelectionSetWindow, Point1, Point2 'ByPolygon acSelectionSetWindow, Point3 'ObjSelection.Select acSelectionSetWindow, Point1, Point2 'Set ObjSelection = SelectionSets.Item ' objSelection.Clear ' Set objObjet = objSelection ' objSelection.AddItems objObjets ' objSelection.Erase 'objSelection.SelectByPolygon(acSelectionSetWindowPolygon, 0,0,0 10,15,0) 'Set objselectionset = selectionsetscollection.Add(strCartouche) End Sub Quote
SEANT Posted July 1, 2009 Posted July 1, 2009 Give this a try. Private Sub test() Dim ObjSelection As AcadSelectionSet Dim ObjetOut As AcadEntity Dim Point1(0 To 2) As Double Dim Point2(0 To 2) As Double Dim Point3(0 To 5) As Double 'Data Point1(0) = 0# Point1(1) = 0# Point1(2) = 0# Point2(0) = 10# Point2(1) = 15# Point2(2) = 0# On Error Resume Next ThisDrawing.SelectionSets.Item("TempSSet").Delete On Error GoTo 0 Set ObjSelection = ThisDrawing.SelectionSets.Add("TempSSet") ObjSelection.Select acSelectionSetWindow, Point1, Point2 For Each ObjetOut In ObjSelection ObjetOut.Delete Next ThisDrawing.Regen acAllViewports End Sub Quote
neophyte Posted July 1, 2009 Author Posted July 1, 2009 Thanks That works perfectly. I have a another question, what is ("TempSSet")? Quote
SEANT Posted July 2, 2009 Posted July 2, 2009 When implemented from VBA, selection sets are required to have a name. If a VBA routine tries to create a named selection set that already exist and/or tries to delete a named selection set that does not exist, the routine will crash. There are a couple of ways to deal with those issues; the method I used (the statement between the two “On Error”s) is the most basic. Quote
neophyte Posted July 6, 2009 Author Posted July 6, 2009 Thanks for the hints. Moreover, thanks for taking your time to answer our question Quote
neophyte Posted July 27, 2009 Author Posted July 27, 2009 Hi me again! I forgot, I have to kept a few information. This information is not on the same layer on each drawing. So it's possible to erase part of the drawing but only on one layer, to do a "filter" before erasing the entity? Thanks Quote
SEANT Posted July 27, 2009 Posted July 27, 2009 Yes, all of the Selection methods (though, not Thisdrawing.Utility.GetEntity) support filtering. This thread has and example of using selection filtered by Layer. The example employs the acSelectionSetAll mode, but would work equally well with acSelectionSetWindow. http://www.cadtutor.net/forum/showthread.php?t=38124 Quote
neophyte Posted July 28, 2009 Author Posted July 28, 2009 Your fast! Thanks for the links, I didn't saw this tread Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.