Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
MechMachineMan
in reply to: Anonymous

Here is a sub routine I made that can accomplish what you want with minor modifications. I left in the proper way to change iProps in case you ever need it. You should only need to change things in ChangeIDWiProps Sub amd the ChangeModeliProps Sub.

 

You shouldn't need to uncomment anything to get it working for you; just simply replace with the name of your external rule. HOWEVER, you SHOULD change your iProperty format in your external rule because simply using iProperties.Value("Project", ....) ONLY changes it for the active document, and will thus not work for running an external rule in a document that is not active (i.e.; it will just keep applying the changes inteded for the ipt to the idw). Good luck.

 

 

 

 

 

 

 

Sub Main()

Dim oDwgDoc As DrawingDocument
Try
	oDwgDoc = ThisApplication.ActiveDocument
Catch
	MsgBox("Use Drawing Document Instead")
	Exit Sub
End Try

Dim oSheet As Sheet = oDwgDoc.ActiveSheet
Dim oDrawingView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oModelDoc As Document = ThisApplication.Documents.ItemByName(oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument.FullFileName)

ChangeIDWiProps(oDwgDoc)
ChangeModeliProps(oModelDoc)

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub ChangeIDWiProps(oDoc As DrawingDocument)

'iLogicVb.Automation.RunExternalRule([DOCUMENT OBJECT], [RULE NAME])
iLogicVb.Automation.RunExternalRule(oDoc,"Sheet Name Formatting.txt")

'http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
'oDoc.PropertySets.Item("Inventor Summary Information").Item("Author").Value = ""
'oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = ""
'oDoc.PropertySets.Item("Inventor Document Summary Information").Item("Manager").Value = ""
'oDoc.PropertySets.Item("Inventor User Defined Properties").Item("WO#").Value = ""

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub ChangeModeliProps(oDoc As Document)

'iLogicVb.Automation.RunExternalRule([DOCUMENT OBJECT], [RULE NAME])
iLogicVb.Automation.RunExternalRule(oDoc,"Sheet Name Formatting.txt")

'http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
'oDoc.PropertySets.Item("Inventor Summary Information").Item("Author").Value = ""
'oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = ""
'oDoc.PropertySets.Item("Inventor Document Summary Information").Item("Manager").Value = ""
'oDoc.PropertySets.Item("Inventor User Defined Properties").Item("WO#").Value = ""

End Sub

 

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type