setting drawing sheet properties

setting drawing sheet properties

Miguel.CarvajalS34Q6
Advocate Advocate
1,200 Views
7 Replies
Message 1 of 8

setting drawing sheet properties

Miguel.CarvajalS34Q6
Advocate
Advocate

Hello, I am trying to configure the change in the size of the drawing sheets through a form, but the property where the size (A4, A3, A2. etc) of the sheet is entered is not reflected in the label.
How can I incorporate it into the code so that it changes with each new sheet, generally on all sheets of the drawing. thanks This is the code I'm using for the configuration

 

InventorVb.DocumentUpdate(True)

       

        iLogicForm.Show("FORMATO_DE_HOJA")

 

'FORMATOS

'[

If FORMATO_HOJA = "FORMATO_A4" Then

        ThisApplication.ActiveDocument.ActiveSheet.Orientation = kPortraitPageOrientation

        ActiveSheet.ChangeSize("307", "225" , moveBorderItems := True)

        ActiveSheet.TitleBlock = "FORMATO UTILLAJE"

        ActiveSheet.Border = "FORMATO A4"

       

       

       

End If

 

 

If FORMATO_HOJA = "FORMATO_A4" Then

        ActiveSheet.ChangeSize("307", "225" , moveBorderItems := True)

End If

 

'] FORMATO_A4

 

'[

If FORMATO_HOJA = "FORMATO_A3" Then

        ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation

        ActiveSheet.ChangeSize("307", "430", moveBorderItems := True)

        ActiveSheet.TitleBlock = "FORMATO UTILLAJE"

        ActiveSheet.Border = "FORMATO A3"

       

End If

 

If FORMATO_HOJA = "FORMATO_A3" Then

        ActiveSheet.ChangeSize("307", "430", moveBorderItems := True)

End If

 

'] FORMATO_A3

 

'[

If FORMATO_HOJA = "FORMATO_A2" Then

        ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation

        ActiveSheet.ChangeSize("430,5", "604", moveBorderItems := True)

        ActiveSheet.TitleBlock = "FORMATO UTILLAJE"

        ActiveSheet.Border = "FORMATO A2"

       

End If

 

If FORMATO_HOJA = "FORMATO_A2" Then

        ActiveSheet.ChangeSize("430,5", "604", moveBorderItems := True)

End If

 

'] FORMATO_A2

 

'[

If FORMATO_HOJA = "FORMATO_A1" Then

        ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation

        ActiveSheet.ChangeSize("605", "851", moveBorderItems := True)

        ActiveSheet.TitleBlock = "FORMATO UTILLAJE"

        ActiveSheet.Border = "FORMATO A1"

       

       

End If

 

If FORMATO_HOJA = "FORMATO_A1" Then

        ActiveSheet.ChangeSize("605", "851", moveBorderItems := True)

End If

 

'] FOTMATO_A1

 

'[

If FORMATO_HOJA = "FORMATO_A0" Then

        ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation

        ActiveSheet.ChangeSize("851", "1199", moveBorderItems := True)

        ActiveSheet.TitleBlock = "FORMATO UTILLAJE"

        ActiveSheet.Border = "FORMATO A0"

       

End If

 

If FORMATO_HOJA = "FORMATO_A0" Then

        ActiveSheet.ChangeSize("851", "1199", moveBorderItems := True)

End If

 

']FOTMATO_A0

Replies (7)
Message 2 of 8

Cadkunde.nl
Collaborator
Collaborator

Made those buttons a few times for customers.

Converted my code to ilogic:

 

Sub Main()
	DrawingDown()
'DrawingUp() End Sub Sub DrawingDown() Dim odoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = odoc.ActiveSheet Select Case oSheet.Size Case DrawingSheetSizeEnum.kA3DrawingSheetSize oSheet.Size = DrawingSheetSizeEnum.kA4DrawingSheetSize oSheet.Orientation = PageOrientationTypeEnum.kPortraitPageOrientation Case DrawingSheetSizeEnum.kA2DrawingSheetSize oSheet.Size = DrawingSheetSizeEnum.kA3DrawingSheetSize oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation Case DrawingSheetSizeEnum.kA1DrawingSheetSize oSheet.Size = DrawingSheetSizeEnum.kA2DrawingSheetSize oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation Case DrawingSheetSizeEnum.kA0DrawingSheetSize oSheet.Size = DrawingSheetSizeEnum.kA1DrawingSheetSize oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation End Select InsertDefaultBorder(odoc, oSheet) End Sub Sub DrawingUp() Dim odoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = odoc.ActiveSheet Select Case oSheet.Size Case DrawingSheetSizeEnum.kA4DrawingSheetSize oSheet.Size = DrawingSheetSizeEnum.kA3DrawingSheetSize oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation Case DrawingSheetSizeEnum.kA3DrawingSheetSize oSheet.Size = DrawingSheetSizeEnum.kA2DrawingSheetSize oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation Case DrawingSheetSizeEnum.kA2DrawingSheetSize oSheet.Size = DrawingSheetSizeEnum.kA1DrawingSheetSize oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation Case DrawingSheetSizeEnum.kA1DrawingSheetSize oSheet.Size = DrawingSheetSizeEnum.kA0DrawingSheetSize oSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation End Select InsertDefaultBorder(odoc, oSheet) End Sub Sub InsertDefaultBorder(oDrawDoc As DrawingDocument, oSheet As Sheet) ' Check to see if the sheet already has a border and delete it if it does. If Not oSheet.Border Is Nothing Then oSheet.Border.Delete() End If ' Define the values to use as input for the border creation. Dim HorizontalZoneCount As Long HorizontalZoneCount = 0 Dim HorizontalZoneLabelMode As BorderLabelModeEnum HorizontalZoneLabelMode = BorderLabelModeEnum.kBorderLabelModeNumeric Dim VerticalZoneCount As Long VerticalZoneCount = 0 Dim VerticalZoneLabelMode As BorderLabelModeEnum VerticalZoneLabelMode = BorderLabelModeEnum.kBorderLabelModeAlphabetical Dim LabelFromBottomRight As Boolean LabelFromBottomRight = False Dim DelimitByLines As Boolean DelimitByLines = False Dim CenterMarks As Boolean CenterMarks = False Dim TopMargin As Double TopMargin = 0.5 Dim BottomMargin As Double BottomMargin = 0.5 Dim LeftMargin As Double LeftMargin = 0.5 Dim RightMargin As Double RightMargin = 0.5 'Dim BorderLineWidth As Double 'BorderLineWidth = 0.35 'Dim TextLabelHeight As Double 'TextLabelHeight = 1.5 'Dim Font As String 'Font = "Courier New" ' Add the border to the sheet. This sets all of the values, but any of them ' can be left out and it will default to an appropriate value. Dim oBorder As DefaultBorder = oSheet.AddDefaultBorder(HorizontalZoneCount, HorizontalZoneLabelMode, VerticalZoneCount, VerticalZoneLabelMode, LabelFromBottomRight, DelimitByLines, CenterMarks, TopMargin, BottomMargin, LeftMargin, RightMargin,, ,) End Sub

 

Message 3 of 8

Miguel.CarvajalS34Q6
Advocate
Advocate

I think I did not make myself understood, the only thing I need is that regardless of the size of the sheet, it is inserted if it is A4, A3 or A2 as the case may be, since I put the sheet size property on it and I get another value on the label

0 Likes
Message 4 of 8

JelteDeJong
Mentor
Mentor

I think you can shorten your rule like this:

InventorVb.DocumentUpdate(True)
iLogicForm.Show("FORMATO_DE_HOJA")

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet

ActiveSheet.TitleBlock = "FORMATO UTILLAJE"
sheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation

Select Case FORMATO_HOJA
    Case "FORMATO_A4"
        sheet.Orientation = PageOrientationTypeEnum.kPortraitPageOrientation
        sheet.Size = DrawingSheetSizeEnum.kA4DrawingSheetSize
        ActiveSheet.Border = "FORMATO A4"
    Case "FORMATO_A3"
        sheet.Size = DrawingSheetSizeEnum.kA3DrawingSheetSize
        ActiveSheet.Border = "FORMATO A3"
    Case "FORMATO_A2"
        sheet.Size = DrawingSheetSizeEnum.kA2DrawingSheetSize
        ActiveSheet.Border = "FORMATO A2"
    Case "FORMATO_A1"
        sheet.Size = DrawingSheetSizeEnum.kA1DrawingSheetSize
        ActiveSheet.Border = "FORMATO A1"
    Case "FORMATO_A0"
        sheet.Size = DrawingSheetSizeEnum.kA0DrawingSheetSize
        ActiveSheet.Border = "FORMATO A0"
End Select

This is shorter and uses the Inventor API instead of the iLogic API with the advantage that you can use default Inventor features.  In your title block you can use a text block with the parameter <Sheet Size>

JelteDeJong_0-1681848804467.png

 

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 8

Cadkunde.nl
Collaborator
Collaborator

Oops was a bit too short in my explanation.

In your code you change the size of the current sheet by length and width.

 

In my code I use:

DrawingSheetSizeEnum.kA3DrawingSheetSize

So i change it to a formatted style A4, A3 etc.

And you can call this in your titleblock with Drawing--> Sheetsize.

JelteDeJong already made screenshot of that

0 Likes
Message 6 of 8

Juan_Baron6NFHE
Explorer
Explorer

The code works perfectly, but it only works with standard sheet sizes. For administrative reasons, the labels we use in the company are a little larger, so when executing the code, the sheet is adjusted, leaving the frames outside the sheet.

How can this event be resolved?

Captura112233123.JPG

0 Likes
Message 7 of 8

Miguel.CarvajalS34Q6
Advocate
Advocate

In conclusion I need to change the value of <sheet size> for the title of the sheet, that if the sheet has the title "A4", then the sheet size is A4

Message 8 of 8

JelteDeJong
Mentor
Mentor

If I understand correctly you have custom pare sizes. (A4 is not really A4.) That complicates the question a bit. Because then you can't use the default paper sizes and default <Sheet Size> property.  <Sheet Size> will show "Custom size". But You could create a prompted entry, called "Custom sheet size", in your title block.

JelteDeJong_0-1681938421504.png

Then you could fill in that prompted entry with iLogic. Your code would look something like this:

InventorVb.DocumentUpdate(True)
iLogicForm.Show("FORMATO_DE_HOJA")

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet

ActiveSheet.TitleBlock = "FORMATO UTILLAJE"
sheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation

Dim format = "A4"
Select Case FORMATO_HOJA
    Case "FORMATO_A4"
        sheet.Orientation = PageOrientationTypeEnum.kPortraitPageOrientation
        ActiveSheet.ChangeSize("307", "225", moveBorderItems:=True)
        ActiveSheet.Border = "FORMATO A4"
        format = "A4"
    Case "FORMATO_A3"
        ActiveSheet.ChangeSize("307", "430", moveBorderItems:=True)
        ActiveSheet.Border = "FORMATO A3"
        format = "A3"
    Case "FORMATO_A2"
        ActiveSheet.ChangeSize("430,5", "604", moveBorderItems:=True)
        ActiveSheet.Border = "FORMATO A2"
        format = "A2"
    Case "FORMATO_A1"
        ActiveSheet.ChangeSize("605", "851", moveBorderItems:=True)
        ActiveSheet.Border = "FORMATO A1"
        format = "A1"
    Case "FORMATO_A0"
        ActiveSheet.ChangeSize("851", "1199", moveBorderItems:=True)
        ActiveSheet.Border = "FORMATO A0"
        format = "A0"
End Select

' Set the prompted entry
Dim titleBlock As TitleBlock = sheet.TitleBlock
For Each textBox As TextBox In titleBlock.Definition.Sketch.TextBoxes
    If (textBox.Text = "Custom sheet size") Then
        Dim uom = doc.UnitsOfMeasure
        Dim x = Math.Round(uom.ConvertUnits(sheet.Width, UnitsTypeEnum.kDatabaseLengthUnits, UnitsTypeEnum.kDefaultDisplayLengthUnits), 1)
        Dim y = Math.Round(uom.ConvertUnits(sheet.Height, UnitsTypeEnum.kDatabaseLengthUnits, UnitsTypeEnum.kDefaultDisplayLengthUnits), 1)
        Dim sheetSize = String.Format("{0} ({1}x{2})", format, x, y)
        titleBlock.SetPromptResultText(textBox, sheetSize)
    End If
Next

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com