I have an IDW file that has a corresponding .IPT Everytime you import a .ipt onto a sheet, a text accompanies it. I want to write a macros to edit this text.
As an usual practise it gives "VIEW, DESCRIPTION and SCALE" .
Instead of VIEW , I want the code to pick something from the i-properties.
Eg. Instead of VIEW, it shopuld write the STOCK NUMBER from the iproperties of the part.
Is this possible ?
Hi subbbu,
There are a couple of iLogic examples at this link that should get you very close to what you're looking for:
http://inventortrenches.blogspot.com/2012/01/set-your-drawing-view-labels-to-use.html
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Hello Curtis,
Thanks but I cant access blogs from workplace and I my systems at home do not have inventor for me to try on .
Is the a way around ? Something which is on this forum , may be ?
Hi subbbu,
Ok, here's a quick example that adds the stock number iProperty from the model in the view to the current view name:
'Define the open document Dim openDoc As Document openDoc = ThisDoc.Document 'Look at the model file referenced in the open document Dim docFile As Document docFile = ThisDoc.ModelDocument 'format model file name Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 'define the property set customPropertySet = docFile.PropertySets.Item("Inventor User Defined Properties") 'define stock number property oStockNumber = iProperties.Value(docFName, "Project", "Stock Number") Dim oSheets As Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView 'get the drawing sheet collection oSheets = openDoc.Sheets 'look at each sheet in the sheet collection For Each oSheet In oSheets 'get the drawing view collection oViews = oSheet.DrawingViews 'look at each view in the view collection For Each oView In oViews 'capture the current view label ViewLabel = oView.Name 'change view name to "Name - Stock Number" 'example: View1 - SN100 oView.Name = ViewLabel & " - " & oStockNumber Next Next
And here's a quick example that adds the stock number iProperty from the model in the view to the current view label:
'Define the open document Dim openDoc As Document openDoc = ThisDoc.Document 'Look at the model file referenced in the open document Dim docFile As Document docFile = ThisDoc.ModelDocument 'format model file name Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 'define the property set customPropertySet = docFile.PropertySets.Item("Inventor User Defined Properties") 'define stock number property oStockNumber = iProperties.Value(docFName, "Project", "Stock Number") Dim oSheets As Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView 'get the drawing sheet collection oSheets = openDoc.Sheets 'look at each sheet in the sheet collection For Each oSheet In oSheets 'get the drawing view collection oViews = oSheet.DrawingViews 'look at each view in the view collection For Each oView In oViews 'change view name to "Name - Stock Number" 'example: View1 - SN100 oView.Label.FormattedText = "<DrawingViewName/>" & " - " & oStockNumber 'or use this line to add the stock number to the 2nd line of the view label 'oView.Label.FormattedText = "<DrawingViewName/><Br/>" & oStockNumber Next Next
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com