Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
i have two rules, first one changes the title block and the boom style, second one changes a sketched symbol. The code runs only if i have one sheet.
Need help to run the code through all Sheets.
First one:
ActiveSheet.TitleBlock = "ET-Liste Deutsch" Dim openDoc As Document openDoc = ThisDoc.Document 'Dim docFile As Document If openDoc.DocumentType = 12292 Then 'Look For the model referenced within the drawing. End the Rule If the drawing Is empty. Dim MDocFile As Document If ThisDoc.ModelDocument IsNot Nothing Then MDocFile = ThisDoc.ModelDocument Else MessageBox.Show("Diese Option ist in einer leeren Zeichnung unzulässig", "Export error") Return End If 'assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument 'Set a reference to the active sheet. Dim oSheet As Sheet oSheet = oDrawDoc.ActiveSheet 'Look for partlist within drawing. End rule, if it doesn't exist. 'say there is a Partslist on the sheet. Dim oPartslist As PartsList oPartslist = oSheet.PartsLists(1) If oSheet.PartsLists(1) IsNot Nothing Then 'set parts list to a specific style oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("KV-Stueli_Deutsch") End If Else MessageBox.Show("Es muss eine IDW offen sein um den Code zu verwenden!", "File Type Mismatch!") End If iLogicVb.RunRule("Flagge")
Second one:
Dim oIDW As DrawingDocument = ThisDoc.Document Dim oSheet As Sheet = oIDW.ActiveSheet ' First view Dim oView As DrawingView = oSheet.DrawingViews.Item(1) ' If base view If oView.ViewType <> kStandardDrawingViewType Then ' If ref file is sheet metal Dim oRefFile As Document = oIDW.ReferencedDocuments.Item(1) Dim oSymbol As SketchedSymbol If ActiveSheet.TitleBlock = "ET-Liste Deutsch" Then ' Define which symbol Dim oSymDef_DE As SketchedSymbolDefinition Dim oSymDef_EN As SketchedSymbolDefinition oSymDef_DE = oIDW.SketchedSymbolDefinitions.Item("FL_Deutsch") oSymDef_EN = oIDW.SketchedSymbolDefinitions.Item("FL_Englisch") Dim oDoc As DrawingDocument oDoc = ThisDoc.Document Dim oSheets As Sheets oSheets = oDoc.Sheets Dim oSheet1 As Sheet Dim oSymbols As SketchedSymbols 'iterate through all of the sheets For Each oSheet1 In oSheets 'remove existing sketched symbols named View Label For Each oSymbol In oSheet1.SketchedSymbols If oSymbol.Definition.Name = "FL_Englisch" Then oSymbol.Delete Else End If Next Next ' Check if symbol has been used If oSymDef_DE.IsReferenced Then Exit Sub ' Set position Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(38,8) ' Insert symbol oSymbol = oSheet.SketchedSymbols.Add(oSymDef_DE, oPosition) End If If ActiveSheet.TitleBlock = "ET-Liste Englisch" Then ' Define which symbol Dim oSymDef_DE As SketchedSymbolDefinition Dim oSymDef_EN As SketchedSymbolDefinition oSymDef_DE = oIDW.SketchedSymbolDefinitions.Item("FL_Deutsch") oSymDef_EN = oIDW.SketchedSymbolDefinitions.Item("FL_Englisch") Dim oDoc As DrawingDocument oDoc = ThisDoc.Document Dim oSheets As Sheets oSheets = oDoc.Sheets Dim oSheet1 As Sheet Dim oSymbols As SketchedSymbols 'iterate through all of the sheets For Each oSheet1 In oSheets 'remove existing sketched symbols named View Label For Each oSymbol In oSheet1.SketchedSymbols If oSymbol.Definition.Name = "FL_Deutsch" Then oSymbol.Delete Else End If Next Next ' Check if symbol has been used If oSymDef_EN.IsReferenced Then Exit Sub ' Set position Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(38,8) ' Insert symbol oSymbol = oSheet.SketchedSymbols.Add(oSymDef_EN, oPosition) End If End If
Thanks for your help....
Regards Martin
Solved! Go to Solution.