Danke nicht mir danke dem Mailschreiber :-)
-----Ursprüngliche Nachricht-----
Von: LARONI [mailto:LARONI@tdcadsl.dk]
Gesendet: Montag, 26. Mai 2003 20:27
An: Juergen
Betreff: Re: Apprentice / IV papersize
Hi Jürgen
You can use the following sub's, beware of wrapping and my comments:
This is for Inventor 5.3, as the sheetinfo is only available through the
ApprenticeServer
The sheetinfo is returned in an array because there could be more than one
sheet :-)
Be aware, that you can't start apprentice from within Inventor VBA, so
hopefully you are using IV6 and later, or have access to VB.
Public Sub GetIV53SheetInfo(FName As String, SheetArray() As String)
Dim OApprentice As New ApprenticeServerComponent
Dim oDoc As ApprenticeServerDrawingDocument 'Routine is
called when an IDW is open, so this is alright
Dim t As Long
On Error Resume Next
t = 0
ReDim Preserve SheetArray(t)
Set oDoc = OApprentice.Open(FName)
If Err Then
Err.Clear
Exit Sub
End If
For t = 1 To oDoc.Sheets.Count
ReDim Preserve SheetArray(t - 1)
oDoc.Sheets(t).Activate
SheetArray(t - 1) = oDoc.Sheets.Item(t).Width & ";" &
oDoc.Sheets.Item(t).Height & ";" & oDoc.Sheets.Item(t).Type
Next
oDoc.Sheets(1).Activate
Set oDoc = Nothing
Set OApprentice = Nothing
If Err Then Err.Clear
End Sub
This is for Inventor 6 and later.
The drawingdocument is just passed to the routine
Public Sub GetAllSheetInfo(oDoc As Inventor.DrawingDocument, SheetArray() As
String)
Dim t As Long
On Error Resume Next
t = 0
ReDim Preserve SheetArray(t)
For t = 1 To oDoc.Sheets.Count
ReDim Preserve SheetArray(t - 1)
oDoc.Sheets(t).Activate
SheetArray(t - 1) = oDoc.Sheets.Item(t).Width & ";" &
oDoc.Sheets.Item(t).Height & ";" & oDoc.Sheets.Item(t).Type
Next
oDoc.Sheets(1).Activate
End Sub
Then checking with known formats, this was my only solution to my question
in the group, due to the Inventor/Apprentice differences.
Public Function GetPaperSizeFromSheet(SheetW As Double, SheetH As Double) As
String
Dim W As Single
Dim H As Single
Dim s As Single
W = Round(SheetW, 1)
H = Round(SheetH, 1)
If W > H Then
s = W
W = H
H = s
End If
If (W = 21 And H = 29.7) Or (W = 21 And H = 29) Then
GetPaperSizeFromSheet = "A4"
Else
If (W = 21.6 And H = 29.7) Or (W = 21 And H = 29) Then
GetPaperSizeFromSheet = "A"
Else
If (W = 27.9 And H = 43.2) Or (W = 27 And H = 43) Then
GetPaperSizeFromSheet = "B"
Else
If (W = 43.2 And H = 55.9) Or (W = 43 And H = 55) Then
GetPaperSizeFromSheet = "C"
Else
If (W = 55.9 And H = 86.4) Or (W = 55 And H = 86) Then
GetPaperSizeFromSheet = "D"
Else
If (W = 86.4 And H = 111.8) Or (W = 86 And H = 111) Then
GetPaperSizeFromSheet = "E"
Else
If (W = 71.1 And H = 101.6) Or (W = 71 And H = 101) Then
GetPaperSizeFromSheet = "F"
Else
If (W = 84.1 And H = 118.9) Or (W = 84 And H = 118) Then
GetPaperSizeFromSheet = "A0"
Else
If (W = 59.4 And H = 84.1) Or (W = 59 And H = 84) Then
GetPaperSizeFromSheet = "A1"
Else
If (W = 42 And H = 59.4) Or (W = 42 And H = 59) Then
GetPaperSizeFromSheet = "A2"
Else
If (W = 29.7 And H = 42) Or (W = 29 And H = 42) Then
GetPaperSizeFromSheet = "A3"
Else
If (W = 21 And H = 29.7) Or (W = 21 And H = 29) Then
GetPaperSizeFromSheet = "A4"
Else
GetPaperSizeFromSheet = "Custom"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Function
Public Function GetEnumFromPaper(PEnum As String) As Long
Select Case PEnum
Case "A2"
GetEnumFromPaper = Inventor.kPaperSizeA2
Case "A3"
GetEnumFromPaper = Inventor.kPaperSizeA3
Case "A4"
GetEnumFromPaper = Inventor.kPaperSizeA4
Case "A4Small"
GetEnumFromPaper = Inventor.kPaperSizeA4Small
Case "10x14"
GetEnumFromPaper = Inventor.kPaperSize10x14
Case "A5"
GetEnumFromPaper = Inventor.kPaperSizeA5
Case "B4"
GetEnumFromPaper = Inventor.kPaperSizeB4
Case "B5"
GetEnumFromPaper = Inventor.kPaperSizeB5
Case "C"
GetEnumFromPaper = Inventor.kPaperSizeCSheet
Case "Custom"
GetEnumFromPaper = Inventor.kPaperSizeCustom
Case "Default"
GetEnumFromPaper = Inventor.kPaperSizeDefault
Case "D"
GetEnumFromPaper = Inventor.kPaperSizeDSheet
Case "E"
GetEnumFromPaper = Inventor.kPaperSizeESheet
Case "Executive"
GetEnumFromPaper = Inventor.kPaperSizeExecutive
Case "Folio"
GetEnumFromPaper = Inventor.kPaperSizeFolio
Case "Ledger"
GetEnumFromPaper = Inventor.kPaperSizeLedger
Case "Legal"
GetEnumFromPaper = Inventor.kPaperSizeLegal
Case "Letter"
GetEnumFromPaper = Inventor.kPaperSizeLetter
Case "Quarto"
GetEnumFromPaper = Inventor.kPaperSizeQuarto
Case Else
GetEnumFromPaper = 0
End Select
End Function
Notice the missing "A0" and "A1" formats, in Inventor's enum's., use
"custom" instead, and be sure that your printerdriver accepts "custom"
papersizes. Typical it has to be a plotter.
Take a look on my homepage:
www.laroni.dk, under "downloads", there might be something interesting ;-)
You have to be carefull if you are switching between IV5.3 and IV6/7, as
Apprentice is very "picky".
You are welcome to return, if you have problems.
Regards
Lars Nielsen
----- Original Message -----
From: "Juergen" <juergen@kacaju.de>
To: <LARONI@tdcadsl.dk>
Sent: Monday, May 26, 2003 7:43 PM
Subject: Re: Apprentice / IV papersize
> Hi Lars,
>
> I have to write a Plottool. Do you know how I get the Papersize of the
> Sheets in an IDW?
>
> Thnx for your support
>
> Juergen Wagner
>
> "Lars R Nielsen" <LARONI@tdcadsl.dk> schrieb im Newsbeitrag
> news:<AC9BBEEE071160FF2BC859CA0088C11A@in.WebX.maYIadrTaRb>...
> > Hi
> >
> > Running both 5,3 and 6.
> >
> > When reading sheetsize in Inventor and Apprentice for the same
papersize,
> I
> > get two different results:
> >
> > Example is for A4
> >
> > Inventor returns: W x H of 21 x 29,7 cm's which is the correct size
> > Apprentice returns: W x H of 21 x 29 cm's, which is wrong
> >
> > The code doesn't do a "round-off" and the returned datatype is "double"
in
> > both cases.
> >
> > Can anybody verify this ?
> >
> > Other sheetsizes that would return decimals is rounded by Apprentice
too.
> >
> > Running W2K-SP3, IV5,3 and 6 with latest SP's
> >
> > BTW
> > Sorry if this issue has been addressed previously, but I didn't find
any
> > threads about this.
> >
> > Regards
> > Lars Nielsen
> >
> >
> >
>
------------------
Grüsse
Jürgen
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP