Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Converting 'Prompted Entry' variables into iProperties?

1 REPLY 1
Reply
Message 1 of 2
mwnadolny
380 Views, 1 Reply

Converting 'Prompted Entry' variables into iProperties?

Hey there.

 

In my drawing template I have a promted entry form that fills out the title block.

 

I also have some iLogic code that automatically exports PDFs and names them based on iProperties.

 

I would like to include some of my prompted entry text into my PDF creation code, but I don't know how to reference it. I only seem to be allowed to reference iProperties.

 

So I would either liek

1. A way to reference prompted entry text in iLogic code

or

2. A way to convert Prompted Entry into iPorperties.

 

Here is "my" PDF creation code, if necessary. Thank you!

 

 '------start of iLogic-------Dim oDocument As inventor._Document = ThisApplication.documents.itembyname(ThisDoc.PathAndFileName(True))
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extensionoPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

Dim oDrawing As DrawingDocument = ThisDoc.Document

Dim oSheet As Sheet
Dim lPos, rPos,sLen As Long
Dim sSheetName As String
Dim sSheetNumber As Integer
Dim sheetCount As Integer = oDrawing.Sheets.Count

oFolder = oPath & "\PDF"

If Not System.IO.Directory.Exists(oFolder) Then 
    System.IO.Directory.CreateDirectory(oFolder)
End If

For Each oSheet In oDrawing.Sheets

lPos = InStr(oSheet.Name, ":")
sLen = Len(oSheet.Name)
sSheetName = Left(oSheet.Name, lPos -1)
sSheetNumber = Right(oSheet.Name, sLen -lPos)

If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
oOptions.Value("Custom_Begin_Sheet") = sSheetNumber
oOptions.Value("Custom_End_Sheet") = sSheetNumber
End If

If sheetCount = 1 Then
    oDataMedium.FileName = oFolder & "\" & oFileName & "R" & iProperties.Value("Project", "Revision Number") & "" & sSheetName & ".pdf"
ElseIf sheetCount > 1
    oDataMedium.FileName = oFolder & "\" & oFileName & "-0" & sSheetNumber & "R" & iProperties.Value("Project", "Revision Number") & "" & sSheetName & ".pdf"
End If

oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

Next
'------end of iLogic-------
1 REPLY 1
Message 2 of 2
rossano_praderi
in reply to: mwnadolny

Hi,
I'm posting two examples for to read a "PromptedEntry" inside the titleblocks, now you have more options to take your choice.
If you like to convert the "PromptedEntry" as Iproperties in your "Title Block", you have to change the "Title Block" definition through the Inventor interface.
Sub Main()
On Error Resume Next
Dim odrwdoc As DrawingDocument
For Each odrwdoc In ThisApplication.Documents
  If odrwdoc.DocumentType = kDrawingDocumentObject Then
	MsgBox ("DocName : " & odrwdoc.DisplayName & vbCr & "PromptedEntry Values : " & vbCr & pEntry(odrwdoc, "test"))
	iProperties.Value("Custom", "test") = SingolSheetPentry(oDrwDoc, "test")
  End If
Next
End Sub

Function pEntry(oDoc As DrawingDocument, oName As String) As String

Dim oSheet As Sheet
Dim TbDef As TitleBlockDefinition
Dim i As Integer

pEntry = ""

For Each oSheet In oDoc.Sheets
  If oSheet.TitleBlock Is Nothing Then
    pEntry = oSheet.Name & " - Error no TitleBlock"
    Exit Function
  End If
  TbDef = oSheet.TitleBlock.Definition
  For i = 1 To TbDef.Sketch.TextBoxes.Count
    If TbDef.Sketch.TextBoxes.Item(i).Text = oName Then
      pEntry = pEntry & oSheet.TitleBlock.GetResultText(TbDef.Sketch.TextBoxes.Item(i)) & vbCr
    End If
  Next
Next
pEntry = pEntry & vbCr
End Function

Function SingolSheetPentry(oDoc As DrawingDocument, oName As String) As String

Dim oSheet As Sheet = oDoc.ActiveSheet
Dim TbDef As TitleBlockDefinition
Dim i As Integer

  If oSheet.TitleBlock Is Nothing Then
    SingolSheetPentry = oSheet.Name & " - Error no TitleBlock"
    Exit Function
  End If
  TbDef = oSheet.TitleBlock.Definition
  For i = 1 To TbDef.Sketch.TextBoxes.Count
    If TbDef.Sketch.TextBoxes.Item(i).Text = oName Then
      SingolSheetPentry = oSheet.TitleBlock.GetResultText(TbDef.Sketch.TextBoxes.Item(i))
	  Exit Function
    End If
  Next
End Function

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report