iLogic code to change iProperties on each open drawing

iLogic code to change iProperties on each open drawing

Anonymous
Not applicable
1,453 Views
2 Replies
Message 1 of 3

iLogic code to change iProperties on each open drawing

Anonymous
Not applicable

I frequently have to make copies of large sets of drawings and then change only a select few iproperties.  I want to automate this a little.

Dim oDoc As Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
	If oDoc.DocumentType = kDrawingDocumentObject Then
	MsgBox ("it worked once")
	iProperties.Value(ThisDrawing,"Project", "Project")="newproject"
	End If
Next oDoc

This code gives me a message box for each open drawing, but only changes the iProperties on whichever drawing is active when I run the code.

Any thoughts?

Inventor 2013

0 Likes
Accepted solutions (1)
1,454 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor
Accepted solution

 

This might work:

Dim oDoc As Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
	If oDoc.DocumentType = kDrawingDocumentObject Then
	MsgBox ("it worked once")
oDoc.Activate iProperties.Value(ThisDrawing,"Project", "Project")="newproject" End If Next oDoc

 

or if not... 

Dim oDoc As Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
	If oDoc.DocumentType = kDrawingDocumentObject Then
	    MsgBox ("it worked once")
oDoc.PropertySets("Design Tracking Properties")("Project").Value = "newproject" End If Next oDoc

http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html 


--------------------------------------
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
0 Likes
Message 3 of 3

Anonymous
Not applicable

I'm sure theres a reason why

iProperties.Value(ThisDrawing,"Project", "Project")="newproject"

would only ever change the drawing you started with.  Even watching it cycle through all the sheets, and even though the code suggests it should be changing the iproperties, it just wasnt. 

The 2nd suggestion works far better, less code, executes faster, etc. 

Thanks a ton.  I'm new to programming and a minor annoyance to me with VB as I understand compared to some other lower level languages is how many different ways there are to do almost exactly the same thing. 

0 Likes