Message 1 of 11
Modifying custom properties.

Not applicable
03-05-2004
01:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am using the code below to modify Custom User Properties and then print the drawing (with the updated properties). The problem is that the properties on the drawing are still blank when the drawing is printed. When I single-step through the code, the drawing is updated correctly and printed.
I've tried to use the 'sleep' command to slow the code down to let the drawing update, but that hasn't worked. I've tried putting 'DoEvents' calls in but that doesn't help either. I've used the App.Update method right before I print, but the properties still don't update before printing.
Does anyone have any other suggestions? It seems that the only way I can get the drawing to update is to step through the code, which must be giving Inventor enough processing time to update the drawing sheet.
tia
Public Sub ModifyISOBlockInfo(ByVal oDoc As DrawingDocument)
Dim oProperties As PropertySets
Dim oPropertySet As PropertySet
Dim oProperty As Inventor.Property
Set oProperties = oDoc.PropertySets
For Each oPropertySet In oProperties
If (oPropertySet.Name = "Inventor User Defined Properties") Then
For Each oProperty In oPropertySet
'Debug.Print oProperty.Name, oProperty.Value
Select Case LCase(oProperty.Name)
Case "epnumber"
'nothing yet
Case "jobinfo"
oProperty.Value = frmBatchPlot.txtJobDesc.Text
Case "jobquantity"
oProperty.Value = FileRS!qty
Case "pdesc"
oProperty.Value = Trim(FileRS!descr)
Case "pnumber"
oProperty.Value = Trim(FileRS!pnumber)
Case "timenuser"
oProperty.Value = Format(Now, "M/dd/yyyy hh:mm ampm")
End Select
DoEvents
Next oProperty
End If
Next
End Sub
Public Sub PrintInventorDrawing(ByRef oDrawDoc As DrawingDocument)
'Call UpdateStatusBox("Printing " & oDrawDoc.FullFileName)
frmBatchPlot.lblStatus3 = "Plotting"
Call ModifyISOBlockInfo(oDrawDoc)
' Set a reference to the print manager object of the active document.
' This will fail if a drawing document is not active.
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = oDrawDoc.PrintManager
oPrintMgr.NumberOfCopies = frmBatchPlot.txtDrawingCopies
' Set the paper size.
oPrintMgr.PaperSize = kPaperSizeLetter
' Set to print all sheets.
oPrintMgr.PrintRange = kPrintAllSheets
DoEvents
Sleep (10000)
DoEvents
Call CheckFlexGridPosition("Plotted")
' Submit the print.
oPrintMgr.SubmitPrint
oDrawDoc.close
end sub
I've tried to use the 'sleep' command to slow the code down to let the drawing update, but that hasn't worked. I've tried putting 'DoEvents' calls in but that doesn't help either. I've used the App.Update method right before I print, but the properties still don't update before printing.
Does anyone have any other suggestions? It seems that the only way I can get the drawing to update is to step through the code, which must be giving Inventor enough processing time to update the drawing sheet.
tia
Public Sub ModifyISOBlockInfo(ByVal oDoc As DrawingDocument)
Dim oProperties As PropertySets
Dim oPropertySet As PropertySet
Dim oProperty As Inventor.Property
Set oProperties = oDoc.PropertySets
For Each oPropertySet In oProperties
If (oPropertySet.Name = "Inventor User Defined Properties") Then
For Each oProperty In oPropertySet
'Debug.Print oProperty.Name, oProperty.Value
Select Case LCase(oProperty.Name)
Case "epnumber"
'nothing yet
Case "jobinfo"
oProperty.Value = frmBatchPlot.txtJobDesc.Text
Case "jobquantity"
oProperty.Value = FileRS!qty
Case "pdesc"
oProperty.Value = Trim(FileRS!descr)
Case "pnumber"
oProperty.Value = Trim(FileRS!pnumber)
Case "timenuser"
oProperty.Value = Format(Now, "M/dd/yyyy hh:mm ampm")
End Select
DoEvents
Next oProperty
End If
Next
End Sub
Public Sub PrintInventorDrawing(ByRef oDrawDoc As DrawingDocument)
'Call UpdateStatusBox("Printing " & oDrawDoc.FullFileName)
frmBatchPlot.lblStatus3 = "Plotting"
Call ModifyISOBlockInfo(oDrawDoc)
' Set a reference to the print manager object of the active document.
' This will fail if a drawing document is not active.
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = oDrawDoc.PrintManager
oPrintMgr.NumberOfCopies = frmBatchPlot.txtDrawingCopies
' Set the paper size.
oPrintMgr.PaperSize = kPaperSizeLetter
' Set to print all sheets.
oPrintMgr.PrintRange = kPrintAllSheets
DoEvents
Sleep (10000)
DoEvents
Call CheckFlexGridPosition("Plotted")
' Submit the print.
oPrintMgr.SubmitPrint
oDrawDoc.close
end sub