Thomy Posted April 10, 2009 Posted April 10, 2009 Hi, I'm looking for a command to delet/erase my drawing that I draw true VBA. And I want to delete this drawing true a button. I can erase all the drawings. but I just want to erase only the drawing that I draw te last true that program. sombody any idea?? It's for my school project. regards Thomy Quote
SEANT Posted April 10, 2009 Posted April 10, 2009 If I’m following correctly: If the entities require deletion within the scope of the routine then the routine should retain an object reference to them, perhaps via a Global variable, then call Entity.Delete. If the entities persist longer than the duration of the routine – i.e., added to the document, closed, and then reopened – you may have to look into assigning XDATA to your entities via a custom Registered Application Name (DXF code 1001). When deletion is necessary your entities can be retrieved via a selection filter based on the Registered Application Name. Or, your routine can create an save a custom Dictionary that records all the entities added. Later on, the Dictionary can be queried to find the entities that require deletion. The routines would need tom perform all the “house cleaning” to keep the Dictionary up to date. Quote
Thomy Posted April 10, 2009 Author Posted April 10, 2009 Hi, Do jou have an example of this code??? Quote
SEANT Posted April 10, 2009 Posted April 10, 2009 The VBA help section has a good explanation and example of how to use XData. A filtered selection would use these components Dim intCode(0) As Integer Dim varData(0) As Variant Dim TempObjSS As AcadSelectionSet . . . . . intCode(0) = 1001: varData(0) = "Test_Application" ‘code to insure Selection Set does not already exist On Error Resume Next ThisDrawing.SelectionSets.Item("TempSSet").Delete On Error GoTo 0 Set TempObjSS = ThisDrawing.SelectionSets.Add("TempSSet") TempObjSS.Select acSelectionSetAll, , , intCode, varData . . . . . Quote
Thomy Posted April 10, 2009 Author Posted April 10, 2009 Hi, I use Cad 2008 and in the help I can't find somting like "setXdata" or somting simuler. Quote
SEANT Posted April 10, 2009 Posted April 10, 2009 You first have to get to the "ActiveX Automation and VBA" section from help. Quote
Thomy Posted April 10, 2009 Author Posted April 10, 2009 Hi, Which help do you use?? The 1 in VBA or in CAD. Quote
SEANT Posted April 10, 2009 Posted April 10, 2009 Anything specific to AutoCAD can only be found in AutoCADs Help section as shown above. 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.