Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Is there a Easy way to Text box that always writt the part number of the file?

Darkforce_the_ilogic_guy
Advisor

Is there a Easy way to Text box that always writt the part number of the file?

Darkforce_the_ilogic_guy
Advisor
Advisor

Is there a Easy way to Text box that always writt the part number of the file? I would like that if I make a part with an laser cut text, then if I copy it later and create a new file.. the new file will have the new part number lasercut into the part. ? what is the easy way to do that `?

0 Likes
Reply
158 Views
1 Reply
Reply (1)

FINET_Laurent
Advisor
Advisor

Hi @Darkforce_the_ilogic_guy

 

For a begining here is a code that changes a text box.. text. Asuming the text box is alone in the sketch and the said sketch is the second one of the part : 

 

Dim doc As Inventor.PartDocument = ThisApplication.ActiveDocument
Dim pcd As Inventor.PartComponentDefinition = doc.ComponentDefinition
Dim sk As Inventor.PlanarSketch = pcd.Sketches.Item(2)
Dim txtbox As Inventor.TextBox = sk.TextBoxes.Item(1)

Dim newText As String = "Testing"
Dim actualText As String = txtbox.Text
Dim fText As String = txtbox.FormattedText

sk.Edit
txtbox.FormattedText = fText.Replace(actualText, newText)

sk.ExitEdit

 

For the automation I would probably put the rule on the Open Document trigger. It would read the iProperty and put the value instead of the newText string. I guess you could accomplish that ?

Kind regards,

FINET L.

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes