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: 

Form to populate title block

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
vancem
1175 Views, 10 Replies

Form to populate title block

We have std titleblocks that have both custom properties and prompted entries.

The custom entries set the fields that are common to all sheets in the drawing set

The prompted entries set the fields that are spicific to each sheet ie drawing number line 3 of the title.

I am creating a form that will have a group tab to fill in the common fields and another to populate the prompted entries.

 

It is easy to do the custom entries but how do i access the prompted entries and what code do i use to set them from the form?

10 REPLIES 10
Message 2 of 11
mslosar
in reply to: vancem
Message 3 of 11
vancem
in reply to: mslosar

Thanks for that.

 

It will take me a while to work through the code. do i need to have VB express or similar to make this work?

Message 4 of 11
VdVeek
in reply to: vancem

You can also use iLogic for this (Easier than VB.net). Have a look at this blog: http://blogs.rand.com/manufacturing/2014/05/drawing-title-block-forms-dump-the-prompted-entries.html There is a clear video of how to do it.

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 5 of 11
vancem
in reply to: VdVeek

Thanks for that. 

Our title blocks have a 3 x line title setting the first 2 are normaly common to the drawing set and are custom iproperties. I have a form to set these values and all the other entries that are common to the sheet set.

 

The third line is for the individual sheet only along with the drawing numbers and sheet revision. These are curently set to prompted entries.

I would like my form to have a second tab that sets these entries for the active sheet only.

 

Is this possible?

 

I am thinking of some ilogic code that writes the required entries custom iproperties to the active sheet only?

Message 6 of 11
VdVeek
in reply to: vancem

To change or read a Prompted entry you need to search thru the textboxes in your titleblock. The code below searches for a textbox that starts with "<Prompt ReadOnly". This is a way to identify the prompted entry. In this code the founded Prompted entry wil be shown in a messagebox.

I think this code can help you understand the way to solve your question.

Rob.

 

 

Dim oDrawDoc As DrawingDocument
Dim oSheet As Sheet
Dim tb As Inventor.TextBox
Dim oBorder As Border
Dim borderDef As BorderDefinition
Dim oTB1'oTB1 references to Titleblocks
Dim sValue As String

oDrawDoc = ThisApplication.ActiveDocument
oSheet = oDrawDoc.ActiveSheet
oBorder = oSheet.Border
borderDef = oBorder.Definition
oTB1 = oSheet.TitleBlock

 For Each tb In oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes
   		If tb.FormattedText.StartsWith("<Prompt ReadOnly") Then
		sValue = oTB1.GetResultText(tb)
		MessageBox.Show("Property Field: " & tb.Text & vbCrLf & "Value: " & sValue & vbCrLf & "Prompted Entry: " & tb.FormattedText, "Prompted entry")
	End If
Next
Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 7 of 11
vancem
in reply to: VdVeek

Thanks for that.

I'll give it a go.

Cheers Vance
Message 8 of 11
vancem
in reply to: VdVeek

Rob,

 

I have had a chance to get your code to work and have been able to identify the unique names for the prompted entries that I wish to populate from a form. I have added reference paramaters to the title block and linked those parameters to the form.

 

Your code searches for "tb.FormattedText.StartsWith("<Prompt ReadOnly")".

As I am not very experienced in VB code I am not sure what code to use to call up the individual prompted entry ie ("<Prompt ReadOnlyUniqueID='8'>DRAWING NO.</Prompt>")

 

Any assistance would be appreciated.

 

Regards Vance

Message 9 of 11
VdVeek
in reply to: vancem

To get acces to your Prompted Entry you can use the code below.

In the screencapture you see that my Prompted Entry name is <TEST>

 

For Each tb In oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes  

If tb.Text = "<TEST>" Then

 MsgBox ("YES!")        

Else

MsgBox ("No")

End If

Next

 

Capture.PNG

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 10 of 11
vancem
in reply to: VdVeek

Hi Rob,

 

I am still having Trouble getting this code to set the prompted entries from a Form.

 

I can find the prompted entries, and get the value of the prompted entry to show in a message box.

 

In ther code below I can get as far the highlited section but am unsure of what code to use to set the prompted entry to "oDrwNo"

oDrwNo is set from a reference parameter that is set via my form.

I know there is somthing simple that I am missing, any help would be gratfull recieved.

 

 

 

Dim oDrawDoc As DrawingDocument

Dim oSheet As Sheet

Dim tb As Inventor.TextBox

Dim oBorder As Border

Dim borderDef As BorderDefinition

Dim oTB1'oTB1 references to Titleblocks

Dim sValue As String

Dim oDrwNo

Dim oPromptEnt As String

 

oDrawDoc = ThisApplication.ActiveDocument

oSheet = oDrawDoc.ActiveSheet

oBorder = oSheet.Border

borderDef = oBorder.Definition

oTB1 = oSheet.TitleBlock

 

For Each tb In oDrawDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes

If tb.Text = "DRAWING NO." Then

           sValue = oTB1.GetResultText(tb)

           oDrwNo = DRAWING_NO

           MessageBox.Show("Property Field: " & tb.Text & vbCrLf & "Value: " & sValue & vbCrLf & "Prompted Entry: " & tb.FormattedText, "Prompted entry")       

           MessageBox.Show("Param drw no  " & oDrwNo, "Title")

 

         ???? Set Prompted entry to = oDrwNo  ????

 

           oPromptEnt = oTB1.GetResultText(tb)

          MessageBox.Show("Prompted value " & oPromptEnt, "Title")

 

       

 

    End If

Next

 

 

 

Regards Vance

 

Message 11 of 11
VdVeek
in reply to: vancem

Vance Your missing line is:

         '???? Set Prompted entry To = oDrwNo  ????         
Call oDrawDoc.ActiveSheet.TitleBlock.SetPromptResultText(tb, oDrwNo)
Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.

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

Post to forums  

Autodesk Design & Make Report