Insert partnumber on a surface

Insert partnumber on a surface

ctx400
Contributor Contributor
603 Views
6 Replies
Message 1 of 7

Insert partnumber on a surface

ctx400
Contributor
Contributor

Hi there

Isn't it possible to insert Partnumber on a surface as text with ilogic code.
I have found the following on the net and it works almost as desired, but the problem is that the text is not updated if you change Partnumber under iProperties.
I really hope someone has a solution.

 

This is the code i found:

 

Sub Main()
 
'===================================
'This Is a Ilogic Rule To create a Mark From a textbox For engraving
 
 
'===================================
  
 '  a reference to the currently active document.
 ' This assumes that it is a part document.
   Dim oPartDoc As PartDocument
   oPartDoc = ThisApplication.ActiveDocument
 
Dim oCompDef As PartComponentDefinition
oCompDef = oPartDoc.ComponentDefinition
 
  ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
    oTransGeom = ThisApplication.TransientGeometry
 
'================ Pasted to pick the face where the Mark has to come ============================
 
'Select Face and Edges to dimension sketch circles from
Dim oFrontFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Text On")
 
'============================================================
 
   ' Create a new sketch on this face
   oSketch = oCompDef.Sketches.AddWithOrientation(oFrontFace, _
   oCompDef.WorkAxes.Item(1), True, True, oCompDef.WorkPoints(1))
 
   ' Determine where in sketch space the point (0.5,0.5,0) is.
   Dim oCorner As Point2d
   oCorner = oSketch.ModelToSketchSpace(oTransGeom.CreatePoint(0.5, 0.5, 0))
 
 
' ===================== Create a Custom Parameter in Iproperties "Partnummer"======================
 
'Creating Custom IProperty with filenumber in it calling it Partnummer
 
iProperties.Value("Custom", "Partnummer") = ThisDoc.FileName(False) 'false = without extension
iProperties.Value("Custom", "Partnummer") = (Left(ThisDoc.FileName(False),14))
 
'Creating a UserParameter Where the Partnummer value Is put In
 
Dim PropValue As String = iProperties.Value("Custom", "Partnummer")
 
'updates the user-defined Text Parameter
TagName = PropValue
 
'================================ Create a textbox in the Sketch to place the Iporp Partnummer ====================
 
'     Create Text With simple String As Input.  Since this doesn't use
'     any Text Overrides, it will Default To the active Text Style.
   
Dim oTG As TransientGeometry
   oTG = ThisApplication.TransientGeometry
 
Dim sText As String
   sText = TagName
   Dim oTextBox As TextBox
   oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(1, 1), sText)
 
'==================== Creating an Objectcollection to be Marked ======================
    Dim oSketchObjects As ObjectCollection
    oSketchObjects = ThisApplication.TransientObjects.CreateObjectCollection
    
    ' Get all entities in the sketch
Dim oSketchText As TextBox
    For Each oSketchText In oSketch.TextBoxes
        oSketchObjects.Add(oSketchText)
Next
 
'==================== Creating the Mark on the textbox  ======================
 
    Dim oMarkFeatures As MarkFeatures
    oMarkFeatures = oCompDef.Features.MarkFeatures
    
    ' Get a mark style.
    Dim oMarkStyle As MarkStyle
    oMarkStyle = oPartDoc.MarkStyles.Item(1)
    
' Create mark definition.
Dim oMarkDef As MarkDefinition
oMarkDef = oMarkFeatures.CreateMarkDefinition(oSketchObjects, oMarkStyle)
 
' Create a mark feature.
Dim oMark As MarkFeature
oMark = oMarkFeatures.Add(oMarkDef)
 
'====================   
 
End Sub

 

0 Likes
604 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

In the original rule the text is place only as text. What you need is formatted text. In Inventor 2020 only parameters are available as formatted text. If you have a later version perhaps the iproperty is available directly. In that case retrieve the formatted text via the sub routine 'RetrieveFormattedText" below. 

You can use a parameter to hold the iproperty. Then a local rule will push iproperty to parameter or just change the parameter directly. Ensure the two don't conflict each other. 

This is the line  which creates the formatted text code. 

	'Parameter Field (formatted text). 
	Dim sText As String = "<Parameter Resolved='True' ComponentIdentifier='" & FullFileName & "' Name='PartNo' Precision='3'>""</Parameter>"

 

 

Sub Main()

	' This assumes that currently active document is a part document.
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	
	Dim FullFileName As String = oPartDoc.FullFileName
	
	Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition

	' Find Sketch named already For marking so the user can delete it
	For Each oSketchCheck As PlanarSketch In oPartCompDef.Sketches
		If oSketchCheck.Name = "MarkingSketch" Then
			MessageBox.Show("A sketch named " & oSketchCheck.Name & " already exists. Please Delete this sketch", "Controle op MarkingSketch")
			Return
		End If
	Next

	' Select Face and Edges to place the textbox in a certain direction = Van JelteDejong Forum
	Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Textbox")
	Dim oHorizontalEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Horizontal Edge of Tekeningnummer on Face")
	Dim orignVertex As Vertex = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Select Point (vertex) on the plane")
	Dim testVertex As Vertex = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Select a 2nd Point (vertex) that is on a positive point in the sketch and not on the axes")

	' Add Sketch and set sketch origin point to the stopVertex of the FrontEdge, this is where the TextBox starts
	Dim oSketch As PlanarSketch = oPartCompDef.Sketches.Add(oFace, False)

	oSketch.AxisEntity = oHorizontalEdge
	oSketch.OriginPoint = orignVertex
	oSketch.NaturalAxisDirection = True

	' Check if the testVertex has positive coordinates  = Van JelteDejong Forum
	Dim testPoint As Point2d = oSketch.ModelToSketchSpace(testVertex.Point)
	If (testPoint.X <= 0 Or testPoint.Y <= 0) Then
		oSketch.NaturalAxisDirection = False
	End If

	testPoint  = oSketch.ModelToSketchSpace(testVertex.Point)
	Dim positiveQuadrantIsOnPlane = (testPoint.Y >= 0)	

	iProperties.Value("Custom", "CustomPartNo") = (Left(ThisDoc.FileName(False), 14))	

	' Creating a UserParameter Where the Tekeningnummer value Is put In
	Dim PropValue As String = iProperties.Value("Custom", "CustomPartNo")
	Dim userParams As UserParameters = oPartCompDef.Parameters.UserParameters
	Dim newParam As Parameter
	Try
	newParam = userParams.Item("PartNo")
	Catch
	' Create a parameter and add the iprop
	newParam = userParams.AddByValue("PartNo", PropValue, UnitsTypeEnum.kTextUnits)
	End Try

	'Parameter Field (formatted text). 
	Dim sText As String = "<Parameter Resolved='True' ComponentIdentifier='" & FullFileName & "' Name='PartNo' Precision='3'>""</Parameter>"

	' Set a reference to the transient geometry object.
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	
	Dim oTextBox As Inventor.TextBox
	If (positiveQuadrantIsOnPlane) Then
		oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0.3, 0.5), sText)
	Else
		oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0.3, -0.3), sText)
	End If								

	'Changing Font and/or size
	Dim dTextSize As Double = 0.4 ' value is in cm.  equals .125 in
	'Dim sTextFont As String = "SIMPLEX"
	
	'Set the text box to Parameter field
	oTextBox.FormattedText = sText

	Dim oSketchObjects As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	' Get all entities in the sketch
	For Each oSketchText As Inventor.TextBox In oSketch.TextBoxes
		oSketchObjects.Add(oSketchText)
	Next

	Dim oMarkFeatures As MarkFeatures = oPartCompDef.Features.MarkFeatures
		
	' Get a mark style.
	Dim oMarkStyle As MarkStyle = oPartDoc.MarkStyles.Item(1)
		
	' Create mark definition.
	Dim oMarkDef As MarkDefinition = oMarkFeatures.CreateMarkDefinition(oSketchObjects, oMarkStyle)
		
	' Create a mark feature.
	Dim oMark As MarkFeature = oMarkFeatures.Add(oMarkDef)

	'Naming the sketch And markfeature For detection In future
	oSketch.Name = "MarkingSketch"
	oMark.Name = "Gravering Tekeningnummer"

	oPartDoc.Save
	
End Sub

 Rule to update parameter using on change iproperty event trigger

 PartNo = iProperties.Value("Custom", "CustomPartNo")
 
 RuleParametersOutput()
 InventorVb.DocumentUpdate()

 

How to retrieve formatted text from a text box

Sub RetrieveFormattedText()
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
	Dim oSketch As PlanarSketch = oPartCompDef.Sketches(1)
	Dim oTextBox As Inventor.TextBox = oSketch.TextBoxes(1)
	sFormattedText = InputBox("","FormattedText",oTextBox.FormattedText)
End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 7

ctx400
Contributor
Contributor

Thank you very much it worked perfectly.

I have made a few changes in order to add the revision number as well, but i can't get it to work.

Can you please help me, i'm not that strong in Ilogic.

This is what i got so far but i get an error, BTW i'm running Inventor 2023.

 

Sub Main()
 
' This assumes that currently active document is a part document.
Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
 
Dim FullFileName As String = oPartDoc.FullFileName
 
Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
 
' Find Sketch named already For marking so the user can delete it
For Each oSketchCheck As PlanarSketch In oPartCompDef.Sketches
If oSketchCheck.Name = "Graverings Sketch" Then
MessageBox.Show("En sketch med navnet " & oSketchCheck.Name & " eksisterer allerede. Slet denne sketch først.", "Controle op MarkingSketch")
Return
End If
Next
 
' Select Face and Edges to place the textbox in a certain direction = Van JelteDejong Forum
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Textbox")
Dim oHorizontalEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Horizontal Edge of Tekeningnummer on Face")
Dim orignVertex As Vertex = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Select Point (vertex) on the plane")
Dim testVertex As Vertex = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Select a 2nd Point (vertex) that is on a positive point in the sketch and not on the axes")
 
' Add Sketch and set sketch origin point to the stopVertex of the FrontEdge, this is where the TextBox starts
Dim oSketch As PlanarSketch = oPartCompDef.Sketches.Add(oFace, False)
 
oSketch.AxisEntity = oHorizontalEdge
oSketch.OriginPoint = orignVertex
oSketch.NaturalAxisDirection = True
 
' Check if the testVertex has positive coordinates  = Van JelteDejong Forum
Dim testPoint As Point2d = oSketch.ModelToSketchSpace(testVertex.Point)
If (testPoint.X <= 0 Or testPoint.Y <= 0) Then
oSketch.NaturalAxisDirection = False
End If
 
testPoint  = oSketch.ModelToSketchSpace(testVertex.Point)
Dim positiveQuadrantIsOnPlane = (testPoint.Y >= 0)
 
'*********************************************************************
 
 
'**************************************************************************
 
iProperties.Value("Custom", "CustomPartNo") = (Left(ThisDoc.FileName(False), 14))
 
' Creating a UserParameter Where the Tekeningnummer value Is put In
Dim PropValue As String = iProperties.Value("Custom", "CustomPartNo")
Dim userParams As UserParameters = oPartCompDef.Parameters.UserParameters
Dim newParam As Parameter
Try
newParam = userParams.Item("PartNo")
Catch
' Create a parameter and add the iprop
newParam = userParams.AddByValue("PartNo", PropValue, UnitsTypeEnum.kTextUnits)
End Try
 
'Parameter Field (formatted text).
'****************************************
Dim sText As String = "<Parameter Resolved='True' ComponentIdentifier='" & FullFileName & "' Name='PartNo' Precision='3'>""</Parameter>"
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
'**************************************************************************
 
iProperties.Value("Custom", "CustomRevNo") = iProperties.Value("Project", "Revision Number")
 
' Creating a UserParameter Where the Revisionnummer value Is put In
Dim PropValueRev As String = iProperties.Value("Custom", "CustomRevNo")
Dim userParamsRev As UserParameters = oPartCompDef.Parameters.UserParameters
Dim newParamRev As Parameter
Try
newParamRev = userParams.Item("RevNo")
Catch
' Create a parameter and add the iprop
newParamRev = userParams.AddByValue("RevNo", PropValue, UnitsTypeEnum.kTextUnits)
End Try
 
'Parameter Field (formatted text).
'Dim sTextRev As String = newParamRev
'****************************************
 
' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
 
Dim oTextBox As Inventor.TextBox
If (positiveQuadrantIsOnPlane) Then
oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0.3, 0.5), sText)
Else
oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0.3, -0.3), sText)
End If
 
'Changing Font and/or size
Dim dTextSize As Double = 0.4 ' value is in cm.  equals .125 in
'Dim sTextFont As String = "SIMPLEX"
 
'Set the text box to Parameter field
oTextBox.FormattedText = sText & "-" & newParamRev
 
Dim oSketchObjects As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
 
' Get all entities in the sketch
For Each oSketchText As Inventor.TextBox In oSketch.TextBoxes
oSketchObjects.Add(oSketchText)
Next
 
Dim oMarkFeatures As MarkFeatures = oPartCompDef.Features.MarkFeatures
 
' Get a mark style.
Dim oMarkStyle As MarkStyle = oPartDoc.MarkStyles.Item(1)
 
' Create mark definition.
Dim oMarkDef As MarkDefinition = oMarkFeatures.CreateMarkDefinition(oSketchObjects, oMarkStyle)
 
' Create a mark feature.
'Dim oMark As MarkFeature = oMarkFeatures.Add(oMarkDef)
 
'Naming the sketch And markfeature For detection In future
oSketch.Name = "Graverings Sketch"
'oMark.Name = "Gravering Part Number"
 
oPartDoc.Save
 
End Sub
 
 
 
 
'**************************
Event trigger
 
PartNo = iProperties.Value("Project", "Part Number")
 
 RuleParametersOutput()
 InventorVb.DocumentUpdate()

 

0 Likes
Message 4 of 7

ctx400
Contributor
Contributor

Thank you very much it worked perfectly.

I have made a few changes in order to add the revision number as well, but i can't get it to work.

Can you please help me, i'm not that strong in Ilogic.

This is what i got so far but i get an error, BTW i'm running Inventor 2023.

 

Sub Main()
 
' This assumes that currently active document is a part document.
Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
 
Dim FullFileName As String = oPartDoc.FullFileName
 
Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
 
' Find Sketch named already For marking so the user can delete it
For Each oSketchCheck As PlanarSketch In oPartCompDef.Sketches
If oSketchCheck.Name = "Graverings Sketch" Then
MessageBox.Show("En sketch med navnet " & oSketchCheck.Name & " eksisterer allerede. Slet denne sketch først.", "Controle op MarkingSketch")
Return
End If
Next
 
' Select Face and Edges to place the textbox in a certain direction = Van JelteDejong Forum
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Textbox")
Dim oHorizontalEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Horizontal Edge of Tekeningnummer on Face")
Dim orignVertex As Vertex = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Select Point (vertex) on the plane")
Dim testVertex As Vertex = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Select a 2nd Point (vertex) that is on a positive point in the sketch and not on the axes")
 
' Add Sketch and set sketch origin point to the stopVertex of the FrontEdge, this is where the TextBox starts
Dim oSketch As PlanarSketch = oPartCompDef.Sketches.Add(oFace, False)
 
oSketch.AxisEntity = oHorizontalEdge
oSketch.OriginPoint = orignVertex
oSketch.NaturalAxisDirection = True
 
' Check if the testVertex has positive coordinates  = Van JelteDejong Forum
Dim testPoint As Point2d = oSketch.ModelToSketchSpace(testVertex.Point)
If (testPoint.X <= 0 Or testPoint.Y <= 0) Then
oSketch.NaturalAxisDirection = False
End If
 
testPoint  = oSketch.ModelToSketchSpace(testVertex.Point)
Dim positiveQuadrantIsOnPlane = (testPoint.Y >= 0)
 
'*********************************************************************
 
 
'**************************************************************************
 
iProperties.Value("Custom", "CustomPartNo") = (Left(ThisDoc.FileName(False), 14))
 
' Creating a UserParameter Where the Tekeningnummer value Is put In
Dim PropValue As String = iProperties.Value("Custom", "CustomPartNo")
Dim userParams As UserParameters = oPartCompDef.Parameters.UserParameters
Dim newParam As Parameter
Try
newParam = userParams.Item("PartNo")
Catch
' Create a parameter and add the iprop
newParam = userParams.AddByValue("PartNo", PropValue, UnitsTypeEnum.kTextUnits)
End Try
 
'Parameter Field (formatted text).
'****************************************
Dim sText As String = "<Parameter Resolved='True' ComponentIdentifier='" & FullFileName & "' Name='PartNo' Precision='3'>""</Parameter>"
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
'**************************************************************************
 
iProperties.Value("Custom", "CustomRevNo") = iProperties.Value("Project", "Revision Number")
 
' Creating a UserParameter Where the Revisionnummer value Is put In
Dim PropValueRev As String = iProperties.Value("Custom", "CustomRevNo")
Dim userParamsRev As UserParameters = oPartCompDef.Parameters.UserParameters
Dim newParamRev As Parameter
Try
newParamRev = userParams.Item("RevNo")
Catch
' Create a parameter and add the iprop
newParamRev = userParams.AddByValue("RevNo", PropValue, UnitsTypeEnum.kTextUnits)
End Try
 
'Parameter Field (formatted text).
'Dim sTextRev As String = newParamRev
'****************************************
 
' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
 
Dim oTextBox As Inventor.TextBox
If (positiveQuadrantIsOnPlane) Then
oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0.3, 0.5), sText)
Else
oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0.3, -0.3), sText)
End If
 
'Changing Font and/or size
Dim dTextSize As Double = 0.4 ' value is in cm.  equals .125 in
'Dim sTextFont As String = "SIMPLEX"
 
'Set the text box to Parameter field
oTextBox.FormattedText = sText & "-" & newParamRev
 
Dim oSketchObjects As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
 
' Get all entities in the sketch
For Each oSketchText As Inventor.TextBox In oSketch.TextBoxes
oSketchObjects.Add(oSketchText)
Next
 
Dim oMarkFeatures As MarkFeatures = oPartCompDef.Features.MarkFeatures
 
' Get a mark style.
Dim oMarkStyle As MarkStyle = oPartDoc.MarkStyles.Item(1)
 
' Create mark definition.
Dim oMarkDef As MarkDefinition = oMarkFeatures.CreateMarkDefinition(oSketchObjects, oMarkStyle)
 
' Create a mark feature.
'Dim oMark As MarkFeature = oMarkFeatures.Add(oMarkDef)
 
'Naming the sketch And markfeature For detection In future
oSketch.Name = "Graverings Sketch"
'oMark.Name = "Gravering Part Number"
 
oPartDoc.Save
 
End Sub
 
 
 
 
'**************************
Event trigger
 
PartNo = iProperties.Value("Project", "Part Number")
 
 RuleParametersOutput()
 InventorVb.DocumentUpdate()

 

0 Likes
Message 5 of 7

A.Acheson
Mentor
Mentor

A trick here is to use the line Option Explicit On in the Header. This will help identify some errors before you begin. In the error highlighted below it is saying you can't use the "&" which is used in type string with the parmeter object. 

AAcheson_0-1669699928413.png

 

So when it jumps to the error line you need to figure out why it isn't a string.  And the reason being is that you are not retrieving the value of the parameter which would be a string but rather the object itself. 

AAcheson_1-1669700136384.png

 

Regarding adding the additional rev number. I am assuming your trying to add it in the same text box as the part number. If that is the case you can add both iproperties to one parameter and call it generically a tag. 

See below working code to add the parameter and both iproperties. 

	iProperties.Value("Custom", "CustomPartNo") = (Left(ThisDoc.FileName(False), 14))
	 
	Dim userParams As UserParameters = oPartCompDef.Parameters.UserParameters
	Dim TagParam As Parameter
	Try
		TagParam = userParams.Item("Tag")
	Catch
		' Create a parameter and add the iprop
		TagParam = userParams.AddByValue("Tag", "", UnitsTypeEnum.kTextUnits)
	End Try
	
	TagParam.Value = iProperties.Value("Custom", "CustomPartNo") & "-Rev:" & iProperties.Value("Project", "Revision Number")

	'Parameter Field (formatted text).
	Dim sText As String = "<Parameter Resolved='True' ComponentIdentifier='" & FullFileName & "' Name='Tag' Precision='3'>""</Parameter>"
	

 

'**************************
'Event trigger
Tag = iProperties.Value("Custom", "CustomPartNo")& "-Rev:" & iProperties.Value("Project", "Revision Number")
RuleParametersOutput()
InventorVb.DocumentUpdate()

 

An alternate method to avoid a second rule is to place the parameter creation and updating  at the start of the rule.  This way you can place the sketch rule on a change in iproperty  event trigger and after creation, if the parameter exist then it updates the parameter value then exits the rule. 

iProperties.Value("Custom", "CustomPartNo") = (Left(ThisDoc.FileName(False), 14))
	 
	Dim userParams As UserParameters = oPartCompDef.Parameters.UserParameters
	Dim TagParam As Parameter
	Try
		TagParam = userParams.Item("Tag")
		TagParam.Value = iProperties.Value("Custom", "CustomPartNo") & "-Rev:" & iProperties.Value("Project", "Revision Number")
		Return
	Catch
		' Create a parameter and add the iprop
		TagParam = userParams.AddByValue("Tag", "", UnitsTypeEnum.kTextUnits)
	End Try
	
	TagParam.Value = iProperties.Value("Custom", "CustomPartNo") & "-Rev:" & iProperties.Value("Project", "Revision Number")

	'Parameter Field (formatted text).
	Dim sText As String = "<Parameter Resolved='True' ComponentIdentifier='" & FullFileName & "' Name='Tag' Precision='3'>""</Parameter>"  

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 7

ctx400
Contributor
Contributor

Hi Alan

It works almost perfectly now.

However isn't it possible to run it as an external rule? i can't get it to work.

0 Likes
Message 7 of 7

A.Acheson
Mentor
Mentor

Can you post the rule your using and also a screen shot of the more info tab of the error message box?  if your using the newer Inventor it will also show the line number at fault. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes