I'm looking for a macro that I could customize and that would allow me to look for a property of the model in my active view and once captured, rename the sheet according to this property for all the sheets. We make drawings that include several parts with engraving numbers and it is this engraving number that I would like to import in order to name the tab of my drawing. If you have something, please let me know. Thank you so much! (we are on SW 2016)
Would it be easier to capture a piece of data directly in my drawing and ask that the macro rename the sheet according to this data? Because in the end the number I'm interested in automatically writes in my cartridge! I just find it abont that Dassault is not thinking of integrating this option directly into the leaf properties!!!
Thank you
Thank you for your answer cobra, but I already had this macro but it doesn't take a direct property in the part itself, but either the config name or the part name:(
To retrieve the property in the title block, the easiest way is to loop over the annotations.
Basically, you have to use this type of loop:
Set swView=swDraw.GetFirstView ' Declaration to enable the basemap Set swNote = swView.GetFirstNote swModel.ClearSelection2 (True) Do While Not swNote Is Nothing Set swAnn = swNote.GetAnnotation sValue = "$PRPSHEET:""" & Num_Gravage & """" ' Put the name of the property you are looking for If swNote.PropertyLinkedText = sValue Then swSheet.SetName (swNote.GetText) Exit Sub End If swModel.ClearSelection2 (True) Set swNote = swNote.GetNext Loop
Well, thank you Ceril, but as I'm not a VBA programmer, I'm not too sure where and how to insert your line, here is the code I'm trying to adapt to my needs! If you could give me a hand, that would be great. Thank you
Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swSheet As SldWorks.Sheet Dim swModelview2 As Configuration Dim ConfigName As String Dim vSheets As Variant Dim swView As SldWorks.View Dim i As Integer
Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc
vSheets = swModel.GetSheetNames For i = 1 TB swModel.GetSheetCount swModel.ActivateSheet vSheets(i - 1) Set swSheet = swModel.GetCurrentSheet Count = swModel.GetModelViewCount
Set swView = swModel.GetFirstView
Do While Not swView Is Nothing ConfigName = swView.ReferencedConfiguration Set swView = swView.GetNextView Loop swSheet.SetName ConfigName Next i
Hello, relative to this new macro, is there a way to tell it that the note in which the info I am looking for to rename my tabs is found actually contains more than one property?
The note is composed of 2 properties to form my final number, and I don't know how to tell it the &!
To sum up, how can we tell him to copy the note that contains this property and this property?
Hello Cyril, Here's what I did, but it doesn't work?!
Do While Not swNote Is Nothing Set swAnn = swNote.GetAnnotation sValue = "$PRPSHEET:""No Drawing""" & "$PRPSHEET:""No Piece (Drawing)""" 'Put the name of the property you are looking for' If swNote.PropertyLinkedText = sValue Then swSheet.SetName (swNote.GetText) swModel.EditRebuild3 swModel.Save2 False Exit Do End If swModel.ClearSelection2 (True) Set swNote = swNote.GetNext Loop Next End Sub
I have only copied here the section that interests us.