Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Formatting Text under the views using VBA

4 REPLIES 4
Reply
Message 1 of 5
subbbu
779 Views, 4 Replies

Formatting Text under the views using VBA

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 ?

4 REPLIES 4
Message 2 of 5
Curtis_Waguespack
in reply to: subbbu

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

Message 3 of 5
subbbu
in reply to: Curtis_Waguespack

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 ?

 

 

Message 4 of 5
Curtis_Waguespack
in reply to: subbbu

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:

 

Autodesk Inventor ilogic Drawing View 2.png

 

 

'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:

 

Autodesk Inventor ilogic Drawing View 1.png

 

'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

Message 5 of 5
subbbu
in reply to: Curtis_Waguespack

I tried this. but there werent any changes to the view in the idw. It still should as VIEW

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report