adding sheets to a new drawing

adding sheets to a new drawing

NachoShaw
Advisor Advisor
790 Views
4 Replies
Message 1 of 5

adding sheets to a new drawing

NachoShaw
Advisor
Advisor

Hey

 

i am creating a new drawing from a template automatically and now found that i need to add additional sheets based on the parts i am processing. When i try to add a sheet, i am getting some errors. I have had a look around to see if there is any code about but cant find any.

 

Does anyone have a code sample that lets me add a sheet(s) to a multi sheet in code? Ideally, i dont want to activate the sheet if possible, just want to create the sheet and add the view to the center of the sheet.

 

also, if you have some code that can assess the view size vs the sheet size and rescale to a nominal scale, that would be awesome. 

 

Nominal scales we use

1:1

1:2

1:4

1:5

1:8

1:10

1:20

1:25

1:50

1:100

 

I appreciate any help given 🙂

 

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
791 Views
4 Replies
Replies (4)
Message 2 of 5

Sergio.D.Suárez
Mentor
Mentor

Hi, maybe this simple code example could be useful.
It may help you develop your final rule. Regards

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oCommand As CommandManager= ThisApplication.CommandManager

oCommand.ControlDefinitions.Item("DrawingNewSheetCtxCmd").Execute2(True) 
oSheet.Activate

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 5

NachoShaw
Advisor
Advisor

Hi

 

Thanks for the reply. Is there a way to do this without calling the command function? i need to add new sheets with a specific sheet & size rather than a sheet based on the last or active sheet. I guess i could change the sheet to what i need once created, that wouldnt be an issue, i'll give this a go later 🙂

 

 

Thanks

 

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 4 of 5

Sergio.D.Suárez
Mentor
Mentor

With this example you can add a formatted sheet and place a model on it.
I hope it is a path that can be useful. Regards

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oValueList As New ArrayList

For Each item As SheetFormat In oDrawDoc.SheetFormats
	oValueList.Add(item.Name)
Next

Dim oValue As String = InputListBox("Select Sheet Format", oValueList, oValueList(0), "Add new Sheet with format", "Available Selections")

Dim oFileDlg As Inventor.FileDialog = Nothing
ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt"' |All Files (*.*)|*.*"
oFileDlg.DialogTitle = "Select Model Document"
oFileDlg.InitialDirectory = ThisDoc.Path
oFileDlg.MultiSelectEnabled = True
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If oFileDlg.FileName = "" Then Exit Sub

Dim oModel As Document = ThisApplication.Documents.Open(oFileDlg.FileName, False)

For Each oFormat As SheetFormat In oDrawDoc.SheetFormats
	If oFormat.Name = oValue Then
		Dim oSheet As Sheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat, oModel)
	End If
Next
oModel.Close

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 5 of 5

Sergio.D.Suárez
Mentor
Mentor

With this example you can simply add a sheet. In the comments are the values for the different types of sheets, and their respective orientation.
The titleblock and the default border of the active sheet are added to the last of the code.

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oTitleBlockDef As TitleBlockDefinition = oDrawDoc.ActiveSheet.TitleBlock.Definition

Dim oSheet As Sheet = oDrawDoc.Sheets.Add( 9996,10243, "Sheet", , )

'k12x18InDrawingSheetSize 9999 12 in x         18 in (typically For architectural drawings). 
'k18x24InDrawingSheetSize 10000 18 in x 24 in (typically For architectural drawings). 
'k24x36InDrawingSheetSize 10001 24 in x 36 in (typically For architectural drawings). 
'k30x42InDrawingSheetSize 10003 30 in x 42 in (typically For architectural drawings). 
'k36x48InDrawingSheetSize 10002 36 in x 48 in (typically For architectural drawings). 
'k9x12InDrawingSheetSize 9998 9 in x 12 in (typically For architectural drawings). Default page orientation Is Portrait. 
'kA0DrawingSheetSize 9993 A0 size (typically For metric units). 
'kA1DrawingSheetSize 9994 A1 size (typically For metric units). 
'kA2DrawingSheetSize 9995 A2 size (typically For metric units). 
'kA3DrawingSheetSize 9996 A3 size (typically For metric units). 
'kA4DrawingSheetSize 9997 A4 size (typically For metric units). 
'kADrawingSheetSize 9987 A size (typically For inch units). 
'kBDrawingSheetSize 9988 B size (typically For inch units). 
'kCDrawingSheetSize 9989 C size (typically For inch units). 
'kCustomDrawingSheetSize 9986 Custom size. Does (may) Not fit one Of the standard sizes. 
'kDDrawingSheetSize 9990 D size (typically For inch units). 
'kDefaultDrawingSheetSize 9985 Specifies the Default setting. The more strongly typed value Is the one returned In a query. 
'kEDrawingSheetSize 9991 E size (typically For inch units). 
'kFDrawingSheetSize 9992 F size (typically For inch units). 

'kDefaultPageOrientation 10241 Specifies the Default setting. The more strongly typed value Is returned In a query. 
'kLandscapePageOrientation 10242 Page is oriented As a Landscape. 
'kPortraitPageOrientation 10243 Page is oriented As a Portrait. 

Dim oTitleBlock As TitleBlock = oSheet.AddTitleBlock(oTitleBlockDef)
Dim oBorder As DefaultBorder = oSheet.AddDefaultBorder()

 I hope this helps with your problem. Grettings!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes