I'm looking for a simple macro that would attach all notes in a drawing to a single view, in may case "Drawing view1".
I played around with (swAttachAnnotationOption_e.swAttachAnnotationOption_View) but since I don't know much about VB I'm not getting anywhere. Help would be greatly appreciated.
notes and views
Re: notes and views
Maybe i did not understand you well , but i am not sure why do you need macro.
If the view is highlighted when you drop the note then it will be attached to the view
You can also right click on the note and click "attachment" and then do "attach to view" to link it to a view
If the view is highlighted when you drop the note then it will be attached to the view
You can also right click on the note and click "attachment" and then do "attach to view" to link it to a view
- DanPihlaja
- Posts: 848
- Joined: Thu Mar 11, 2021 9:33 am
- Location: Traverse City, MI
- x 811
- x 978
Re: notes and views
I am not a macro guy...steph wrote: ↑Fri Mar 26, 2021 6:48 am I'm looking for a simple macro that would attach all notes in a drawing to a single view, in may case "Drawing view1".
I played around with (swAttachAnnotationOption_e.swAttachAnnotationOption_View) but since I don't know much about VB I'm not getting anywhere. Help would be greatly appreciated.
But try this:
- Activate the drawings view that you want all notes into
- Select 1 note, then hit CTRL A
- Hit CTRL X to cut all your notes and add them to the Clipboard
- Click inside your activated view and hit CTRL V
- You will have to rearrange them afterward, but they will be all added to the view.
-Dan Pihlaja
Solidworks 2022 SP4
2 Corinthians 13:14
Solidworks 2022 SP4
2 Corinthians 13:14
Re: notes and views
Hello, Try this:
Note: It will attach all the sheet's notes to the first drawing view, but not the notes already attached to a view.
If you also want to do that (i.e attach the other drawing views notes to the first view), try to change:
to
Code: Select all
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swNote As SldWorks.Note
Dim swAnn As SldWorks.Annotation
Dim vNotes As Variant
Dim vNote As Variant
Dim vComps As Variant
Dim vEnts As Variant
Dim swEnt As SldWorks.Entity
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.GetFirstView
swModel.ClearSelection2 True
vNotes = swView.GetNotes
For Each vNote In vNotes
Set swNote = vNote
Set swAnn = swNote.GetAnnotation
If swAnn.OwnerType = swAnnotationOwner_e.swAnnotationOwner_DrawingSheet Then
swAnn.Select3 True, Nothing
End If
Next
Set swView = swView.GetNextView
vComps = swView.GetVisibleComponents
vEnts = swView.GetVisibleEntities2(vComps(0), swViewEntityType_e.swViewEntityType_Face)
Set swEnt = vEnts(0)
swEnt.Select4 True, Nothing
swDraw.AttachAnnotation swAttachAnnotationOption_e.swAttachAnnotationOption_View
End Sub
If you also want to do that (i.e attach the other drawing views notes to the first view), try to change:
Code: Select all
If swAnn.OwnerType = swAnnotationOwner_e.swAnnotationOwner_DrawingSheet Then
Code: Select all
If swAnn.OwnerType = swAnnotationOwner_e.swAnnotationOwner_DrawingSheet Or swAnn.OwnerType = swAnnotationOwner_e.swAnnotationOwner_DrawingView Then
Re: notes and views
Hi Jerome
Thanks for your help, it's very close to what I'm looking for. The macro works for notes that are attached to the sheet, they attached to the "Firstview" but when I try the second option, that is to get all notes from all views, there's no difference.
I added a "Debug.Print swNote.GetText" right after the "Set swAnn = swNote.GetAnnotation" to try to understand a bit more what was going on and the only notes that get listed are the ones that are attached to the sheet. Would you be kind enough to help a little bit more?
Thanks for your help, it's very close to what I'm looking for. The macro works for notes that are attached to the sheet, they attached to the "Firstview" but when I try the second option, that is to get all notes from all views, there's no difference.
I added a "Debug.Print swNote.GetText" right after the "Set swAnn = swNote.GetAnnotation" to try to understand a bit more what was going on and the only notes that get listed are the ones that are attached to the sheet. Would you be kind enough to help a little bit more?
Re: notes and views
Sure. Try this:
Code: Select all
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swNote As SldWorks.Note
Dim swAnn As SldWorks.Annotation
Dim vNotes As Variant
Dim vNote As Variant
Dim vComps As Variant
Dim vEnts As Variant
Dim swEnt As SldWorks.Entity
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.GetFirstView
swModel.ClearSelection2 True
While Not swView Is Nothing
vNotes = swView.GetNotes
For Each vNote In vNotes
Set swNote = vNote
Set swAnn = swNote.GetAnnotation
If swAnn.OwnerType = swAnnotationOwner_e.swAnnotationOwner_DrawingSheet Or swAnn.OwnerType = swAnnotationOwner_e.swAnnotationOwner_DrawingView Then
swAnn.Select3 True, Nothing
End If
Next
Set swView = swView.GetNextView
Wend
Set swView = swDraw.GetFirstView
Set swView = swView.GetNextView
vComps = swView.GetVisibleComponents
vEnts = swView.GetVisibleEntities2(vComps(0), swViewEntityType_e.swViewEntityType_Face)
Set swEnt = vEnts(0)
swEnt.Select4 True, Nothing
swDraw.AttachAnnotation swAttachAnnotationOption_e.swAttachAnnotationOption_View
End Sub
Re: notes and views
Thank you very much, just what I needed
And thanks to the others who also tried to help, greatly appreciated.
And thanks to the others who also tried to help, greatly appreciated.