Get documents part of all opened drawing

Get documents part of all opened drawing

Anonymous
Not applicable
386 Views
1 Reply
Message 1 of 2

Get documents part of all opened drawing

Anonymous
Not applicable

Hello.

 

I'd like to use the iProperty of a part (or an assembly) referenced in a drawing.

But, I need to do that for all opened drawing in Inventor. I tried this, but "doc.ModelDocument" seems not to work...

 

Dim doc As Document
Dim model As Document

For Each doc In ThisApplication.Documents
	If doc.DocumentType = kDrawingDocumentObject Then 
		model = doc.ModelDocument
		model.PropertySets.Item("Inventor User Defined Properties").Item("Size A").Value = 30
	End If
Next

 

0 Likes
Accepted solutions (1)
387 Views
1 Reply
Reply (1)
Message 2 of 2

MechMachineMan
Advisor
Advisor
Accepted solution

Try this:

 

Dim doc As Document
Dim model As Document

For Each doc In ThisApplication.Documents If doc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
'This will only work if there is a drawing view on sheet 1 as that is what it grabs as the document model = doc.Sheets(1).DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
Try model.PropertySets.Item("Inventor User Defined Properties").Item("Size A").Value = 30
Catch
MsgBox("iProp Not Accessible in context of" & vblf & vblf & model.FullFileName)
'need to add the propertyset here through the appropriate methods and then assign value
End try End If Next

 


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