I’m working on some code that goes through all the different views on a drawing sheet (Sheet Format, Drawing Sheet, Drawing Views) and accesses any Sketch Hatches. I am able to access the Sketch Hatches in all the views with the exception of the Sheet Format (AKA Sheet Template).
Here’s a snip of code that deletes the hatches in most of the views successfully. I added the “swDraw.EditTemplate” statement to get it to work on the sheet format, but no luck. Any ideas?
Set swDraw = swModel
swDraw.EditTemplate
Set swSketch = swView.GetSketch
vSketchHatch = swSketch.GetSketchHatches
If Not IsEmpty(vSketchHatch) Then
For i = 0 To UBound(vSketchHatch)
Set swSketchHatch = vSketchHatch(i)
swSketchHatch.Select False
swModel.Extension.DeleteSelection2 swDelete_Absorbed
Next i
End If
swDraw.EditSheet
I believe you would need to get the sketch from the sheet instead of the view, since the sheet format itself will have none. See following link. Hope it helps.
The API Helps says that IModelDoc2::GetActiveSketch2 was superseded by SketchManager:ActiveSketch
Nothing backwards about it. Two different classes.
When COM objects are updated by adding methods or properties the convention is to add a numeric increment to the class name. So ModelDoc becomes ModelDoc2. If a method is changed to add new parameters or change the return type, a numeric increment is applied to the method name. ModelDoc2::GetActiveSketch becomes ModelDoc2::GetActiveSketch2.
The incremented classes and methods aren’t revisions of the originals. They are brand new. The old classes and methods remain for backward compatibility. It’s usually good practice to use the latest versions, unless they have a bug.