- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I am mildly familiar with various coding langue's and have some experience writing code but I am still very new at this. The goal would be that I open the drawing document and run the rule and all of the .ipt parts within the assembly would be un-changed while all of the .iam files within the assembly would ahve there balloons on the sheets altered to a style I created.
I found 2 methods that work separate and I though I could combine them and it would work fine but it doesnt.
The first one changes all the balloons to a new style as shown below and this works as is.
Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oStyles As DrawingStylesManager oStyles = oDrawDoc.StylesManager 'Dim oActiveSheet As Sheet 'oActiveSheet = oDrawDoc.ActiveSheet Dim oSheet As Sheet Dim oBalloon As Balloon Dim oDoc As Document For Each oSheet In oDrawDoc.Sheets For Each oBalloon In oSheet.Balloons oBalloon.Style = oStyles.BalloonStyles.Item("SUB") Next Next
The next one makes a text box appear if the overall doc is an assembly or part as shown below.
'start of iLogic rule - - - - - - - - - - - - - - - - - - doc = ThisDoc.ModelDocument 'check file type If doc.DocumentType = kPartDocumentObject Then MessageBox.Show("This is a part file.", "iLogic") Else If doc.DocumentType = kAssemblyDocumentObject Then MessageBox.Show("This is an assembly file.", "iLogic") End If 'end of iLogic rule - - - - - - - - - - - - - - - - - -
When I tried to combine them everything broke and I'm stuck as shown below.
Dim Doc As DrawingDocument Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oStyles As DrawingStylesManager oStyles = oDrawDoc.StylesManager Dim oSheet As Sheet Dim oBalloon As Balloon Dim oDoc As Document 'Dim Doc As Document For Each oDoc In oSheet.Documents If Doc.DocumentType = kPartDocumentObject Then 'MessageBox.Show("This is a part file.", "iLogic") Else If Doc.DocumentType = kAssemblyDocumentObject Then oBalloon.Style = oStyles.BalloonStyles.Item("SUB") 'MessageBox.Show("This Is an assembly File.", "iLogic") End If Next
Any help would be appreciated if this is the wrong approach for some reason feel free to let me know.
Solved! Go to Solution.