API : Sheet/View Mix and access to TableAnnotation on inactive Sheet

I need to traverse a drawing to obtain all TableAnnotation in it. View::GetFirstTableAnnotation + TableAnnotation::GetNext would make it if I had a View object for every Sheet... It turns out that DrawingDoc::GetFirstView + View::GetNextView traverses only the active Sheet. Note : DrawingDoc::GetFirstView returns a "base" View which corresponds to the active Sheet. How to gain access to inactive sheets base views without changing the active View with DrawingDoc::ActivateSheet or DrawingDoc::SheetNext ? Thanks! Philippe guglielmetti -

formatting link

Reply to
Philippe Guglielmetti
Loading thread data ...

No, I can see no accessor from the ModelDoc object... Perhaps through a SelectByID, but no line is created when I select my table while recording a macro... Did you have another idea ? I did. I tried by traversing the features, but now my problem is to extract the View object from a view feature. GetSpecificFeature doesn't work. Here is my code now: Public Function FindTable(name As String) As SldWorks.TableAnnotation On Error GoTo fail Dim table As SldWorks.TableAnnotation Dim sheets As Variant: sheets = doc.GetSheetNames Dim i As Integer For i = LBound(sheets) To UBound(sheets) Dim f As SldWorks.feature Set f = doc.FeatureByName(sheets(i)) Set f = f.GetFirstSubFeature While Not f Is Nothing Debug.Print f.name; f.GetTypeName If f.GetTypeName = "AbsoluteView" Then Dim view As SldWorks.view Set view = f.GetSpecificFeature2 ' *** DOES NOT WORK

*** While Not view Is Nothing Debug.Print view.name Set table = view.GetFirstTableAnnotation While Not table Is Nothing If table.title = name Then Set FindTable = table: Exit Function Set table = table.GetNext Wend Set view = view.GetNextView Wend End If Set f = f.GetNextSubFeature Wend Next i fail: Debug.Print "Table"; name; "not found" End Function

any idea ? thanks! Philippe Guglielmetti -

formatting link

Reply to
Philippe Guglielmetti

Give this a try I don't have time to test today.

Set View = f

Reply to
CS

You can select a table by ID, but I think you will have to iterate through all the drawing entities and query the entity type in order to filter out the tables. I got the following when manually recording a macro:

boolstatus = Part.Extension.SelectByID2("DetailItem106@Sheet1", "REVISIONTABLE", 0.264032754352, 0.2645043984526, 0, False, 0, Nothing, 0)

I think it would be easier and faster to do this the obvious way - change sheets and use your first method. What is preventing you from doing this? Is it the time required to switch sheets?

Reply to
CoreyK

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.