Open Drawing Document's Model

Open Drawing Document's Model

Anonymous
Not applicable
487 Views
2 Replies
Message 1 of 3

Open Drawing Document's Model

Anonymous
Not applicable

Hello, 

 

I'm trying to create a script that

1. opens a drawing document from a list in a general table

2. once that drawing document is open then open the model within that drawing document

3. run "rule x"

4. save and close the model

5. save and close the drawing

6. move on to the next drawing in the list

 

I can get it to do step one. but I get errors when I try step two. Here is my code:

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim sheet1 as Sheet = oDrawDoc.Sheets("Sheet:1")
Dim table As CustomTable = sheet1.CustomTables.Item(1)
Dim oRow As Row

		''' Iterate through the contents of the parts list.
i = 1
While i <= table.Rows.Count
		
	oRow = table.Rows.Item(i)
	Dim oCell As Cell = oRow.Item(2)
	
	iDoc = iProperties.Value("Summary", "Category") & "\" & oCell.Value & ".idw"
	Dim oDoc As Document = ThisApplication.Documents.Open(iDoc)
		
		ThisApplication.ActiveDocument.Open(ThisDrawing.ModelDocument.FullFileName)

		auto = iLogicVb.Automation
		auto.RunRule(ThisDrawing.ModelDocument, "EXPORT DXF FILES")
				
				
		ThisDrawing.ModelDocument.Save
		ThisDrawing.ModelDocument.Close
	
	oDoc.Save
	oDoc.Close
	
	i=i+1
	
End While

 any help is appreciated.

0 Likes
488 Views
2 Replies
Replies (2)
Message 2 of 3

adam.nagy
Autodesk Support
Autodesk Support

Is it an iLogic code?

It's easier to write things in VBA, because there you get intellisense and would then be pointed to the issue that Document does not have an Open method, but the Documents collection has: 

ThisApplication.Documents.Open(ThisDrawing.ModelDocument.FullFileName)


Adam Nagy
Autodesk Platform Services
Message 3 of 3

Anonymous
Not applicable

I got it working using iLogic but in the future I will look into intellisense. I've never heard of that before. Thanks for the reply.

0 Likes