Compound note

In a drawing I have one compound note, and I want to delete it with a macro. How do I get it (or find it if you want) with a VB-macro, so that I can delete it, or remove it ?

How about if I have several compound notes in a drawing, how do I then find the right one ? Do they have "names" or indexes so that they are recognisable ?

Regards, Trond

Reply to
Trond Svartvatn
Loading thread data ...

Yes they have names just like the features and dimensions in a drawing. They are only accessable through an API though. Finding the right one to delete might be tricky though. You could possibly search for one containing a specific text string.

this will search your template for a note with a specific name and returns its text to a supplied string variable

you will have to edit it to search for specific text and traverse a compound note.

Function getNoteObject(Name As String, ByRef NoteValue As String) As _ SldWorks.note

Dim swNote As SldWorks.note Dim swView As SldWorks.View Set swApp = Application.SldWorks Set Part = swApp.ActiveDoc Set swSheet = Part.GetCurrentSheet() Part.EditTemplate Set swView = Part.GetFirstView Set swNote = swView.GetFirstNote While Not swNote Is Nothing If swNote.GetName = Name Then NoteValue = swNote.GetText Set getNoteObject = swNote Exit Function End If Set swNote = swNote.GetNext Wend Part.EditSheet Part.EditSketch 'Part.ClearSelection Part.EditSketch boolstatus = Part.Extension.SelectByID("Sheet1", "SHEET", _

0.1437811854572, 0.04867757019569, 0, False, 0, Nothing) boolstatus = Part.Extension.SelectByID("Sheet1", "SHEET", _ 0.08464306802756, 0.04139040880625, 0, False, 0, Nothing)

End Function

this is the example that sw help had for traversing a compound note there is more to it so look it up

Compound Note Example (VB)

If (note.IsCompoundNote()) Then

' If object is compound note

count = note.GetTextCount()

' Determine # of text entities

n2 = note.GetTextAtIndex (2)

' Get the 2nd piece of text

n1 = note.GetTextAtIndex (1)

' Get the 1st piece of text

ht2 = note.GetHeightAtIndex (2)

' Get height of 2nd piece of text

End if

Reply to
Corey Scheich

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.