Hi all.
Absolute newbie to iLogic. Hoping someone can help me with my this.
What I'm after is this : When a new IDW is started and the first Base view placed is of a Sheetmetal part, then a Sketched Symbol is placed at a fixed co-ordinate when Save is issued.
From the little iLogic I know I imagine that this would be an external rule that is triggered on Save. Any takers?
Solved! Go to Solution.
Solved by matt_jlt. Go to Solution.
Solved by jdkriek. Go to Solution.
Edit: nevermind I got it 😉
Here we go:
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) If oRefFile.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then ' Define which symbol Dim oSymDef As SketchedSymbolDefinition oSymDef = oIDW.SketchedSymbolDefinitions.Item("NOTES") ' Set position Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10,10) ' Insert symbol Dim oSymbol As SketchedSymbol oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition) End If End If
Thanks Jonathan.
Is this iLogic or VBA? If iLogic is this an external rule or do I need to add it too my IDW template?
Hi Brendan, looking at Jonathan's code it's iLogic, you can tell by the way the objects are set (see below). You can store the rule inside the document or as an external rule. It's up to you. With an external rule you only have to maintain one lot of code and it can be updated very easily but you have to make sure the external rule will not change location or it will throw an error every time you open a new drawing.
iLogic Code (can define and set it in one line)
Dim oSheet As Sheet = oIDW.ActiveSheet
in VBA would have to be
Dim oSheet As Sheet Set oSheet = oIDW.Activesheet
Regards, Matt.
Thanks Jonathan and Matt.
Edit: forget it. I got past the error
To get the symbol placed I have to manually run the rule, which is not much different from manually placing the symbol. Is there any way to get the symbol placement to occur automatically at the time the first view is placed, or on Save?.
Brendan, I modified Jonathan's code so you can run it on a save as. I just added a check to make sure there is a drawing view and to see if the symbol has already been placed so it doesn't double up.
Dim oIDW As DrawingDocument = ThisDoc.Document Dim oSheet As Sheet = oIDW.ActiveSheet ' Check that there is a view on the sheet If oSheet.DrawingViews.Count = 0 Then Exit Sub ' 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) If oRefFile.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then ' Define which symbol Dim oSymDef As SketchedSymbolDefinition oSymDef = oIDW.SketchedSymbolDefinitions.Item("NOTES") ' Check if symbol has been used If oSymDef.IsReferenced Then Exit Sub ' Set position Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10,10) ' Insert symbol Dim oSymbol As SketchedSymbol oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition) End If End If
Regards, Matt.
Thanks Matt, but it doesn't work for me. I deleted all of the existing code and copy/pasted in your update. Then I changed the "NOTES" to be the name of my symbol, and changed the Point2d values. But a Save or Save As doesn't place the symbol.
Did you remember to set the code to run using the event triggers?
On the ribbon>Manage Tab>iLogic Panel>Event Triggers
It looks like two opposing angles overlapping each other.
Remember? I didn't know I had too! I know next to nothing about iLogic.
But I figured it out with your directions. I set it to Before Save Document. And it works great.
Many thanks Matt and Jonathan.