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: 

Insert a Custom Property (as a field) into a textbox which changes when filename changes

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
jeanB99VC
1641 Views, 9 Replies

Insert a Custom Property (as a field) into a textbox which changes when filename changes

Hi There,

 

I want insert a Custom Property into a Textbox as a field, see below Screenshot.

In that way it will change as I change the part.

 

Goal: I want to put the filenumber (custom Iporperty) into a textbox as a field.
Then when I save the file as another number this field will update.

 

My Problem is that I don't know how to insert this field into the textbox.

The code that I have thisfar is:

 

Sub Main()

'===================== DECLERATIONS ===============================
  
 '  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

		Dim oPartCompDef As PartComponentDefinition 
			oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition
		
		oModel=ThisDoc.ModelDocument
		
		
		
		'Creating Custom IProperty with filenumber in it calling it Tekeningnummer
	
	
			iProperties.Value("Custom", "Tekeningnummer") = ThisDoc.FileName(False) 'false = without extension
			iProperties.Value("Custom", "Tekeningnummer") = (Left(ThisDoc.FileName(False),14))	
			
			
	'Get the Property ID For these custom iProperties From the model referenced By the view
		o_iPropID_1 = oModel.PropertySets.Item("Inventor User Defined Properties").Item("Tekeningnummer").PropId	

'format the custom iproperty string and add the property ID
		oString1 = "<Property Document='model' PropertySet='User Defined Properties' " _
		&  "Property='FCE_PartNumber' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
		& o_iPropID_1  & "'>FCE_PartNumber</Property><Br/>"
			
End Sub

 

Hope you can help me with this.

 

PS: This is to complete my engraving rule to automaticly update the engraving when copying the part to another part.

"Ilogic Rule To Mark Textbox on a face with a specific direction for Engraving 

@JelteDeJong

 

Labels (3)
9 REPLIES 9
Message 2 of 10
A.Acheson
in reply to: jeanB99VC

You can added the iproperty by general text, see api sample for vba here for updating exisiting drawings.

Here is the ilogic version of the same code with a sub routine to retrieve an existing iprop formatted text. 

 

Or the alternate method is to add it in the drawing template manually and then just change the iproperty by code. No need for the formatted text then. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 10
dgreatice
in reply to: jeanB99VC

Why you need automation? this case is simple, just use leader note and assign it.

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 4 of 10
jeanB99VC
in reply to: A.Acheson

Hi There,

 

I'm not talking about a drawing.

I want the textfield (Custom Property) to be placed in a sketch on the face of a sheetmetalpart as a field.

Then I can turn it into a mark for engraving. This rule has already been made in another post from me.

I don't understand the help in inventor itself  

 

Goal: I'm looking for the specific method to insert the custom property as a field in the textbox on the face of a part.

 

@Ilogic Rule To Mark Textbox on a face with a specific direction for Engraving

@JelteDeJong 

Message 5 of 10
A.Acheson
in reply to: jeanB99VC

Ok I see it's a part. Your previous post is doing exactly that at this area of the code

Create a textbox in the Sketch to place the Iporp Tekeningnummer ====================

Once the textbox is created then set the formatted text like

 

oTextBox.FormattedText= oString1

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 6 of 10
jeanB99VC
in reply to: A.Acheson

Hi Alan,

 

I'm sorry but I'm not sure what to do where to change what. I have the idea that I'm close but not close enough 🙂 

Is it possible for you to change my rule below so the textbox is filled with the Field of the custom prop instead of the value.

That way if the part is saved as another name the textbox automaticly changes. That was my goal for this rule

I've pasted the rule for engraving below. 

 

Thank you in advance !

 

Sub Main()

'===================== DECLERATIONS ===============================
  
 '  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

		Dim oPartCompDef As PartComponentDefinition 
			oPartCompDef = ThisApplication.ActiveDocument.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)	


' ===================== Create a Custom Parameter in Iproperties "Tekeningnummer"======================

		'Creating Custom IProperty with filenumber in it calling it Tekeningnummer
		
			iProperties.Value("Custom", "Tekeningnummer") = ThisDoc.FileName(False) 'false = without extension
			iProperties.Value("Custom", "Tekeningnummer") = (Left(ThisDoc.FileName(False),14))	
		
		'Creating a UserParameter Where the Tekeningnummer value Is put In
		
		Dim PropValue As String = iProperties.Value("Custom", "Tekeningnummer")
		
		'updates the user-defined Text Parameter
		TagName = PropValue
		
'================================ Create a textbox in the Sketch to place the Iporp Tekeningnummer ====================
	 
		'     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 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
			dTextSize = 0.4 ' value is in cm.  equals .125 in
		Dim sTextFont As String
'			sTextFont = "SIMPLEX"
			oTextBox.FormattedText = "<StyleOverride Font = '" & sTextFont & "' FontSize = '" & dTextSize & "'>" & _
				sText & "</StyleOverride>"


'==================== Creating an Objectcollection to be Marked ======================
    Dim oSketchObjects As ObjectCollection
    	oSketchObjects = ThisApplication.TransientObjects.CreateObjectCollection
    
    ' Get all entities in the sketch
	Dim oSketchText As Inventor.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)

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

Call ZoomAll

oPartDoc.Save
End Sub

Sub ZoomAll
	
'zoom all, this to be sure the part is in ISOmetrich position saved so it is ISO visible in explorer
	ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute

End Sub

 

Message 7 of 10
A.Acheson
in reply to: jeanB99VC

 

Here is what is working. The parameter field is added via formatted text. There is no method to add an iproperty in Inventor 2020 vewrsion at least. Pass in the iproperty value to the parameter to update. 

 

Sub Main()

	'===================== DECLERATIONS ===============================
	  
	' This assumes that currently active document is a part document.
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	
	Dim oFullFileName 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)	

	' ===================== Create a Custom Parameter in Iproperties "Tekeningnummer"======================

	' Creating Custom IProperty with filenumber in it calling it Tekeningnummer
	' Get the Property ID For these custom iProperties From the model referenced By the view
	Dim TekenNum As [Property] = oPartDoc.PropertySets.Item("Inventor User Defined Properties").Item("Tekeningnummer")
	
	TekenNum.Value = (Left(ThisDoc.FileName(False),14))	

	' Creating a UserParameter Where the Tekeningnummer value Is put In
	Dim PropValue As String = TekenNum.Value

	' Updates the user-defined Text Parameter
	TagName = PropValue
	'Parameter Field (formatted text). Manually place a text box an parameter,
	'Then extract Formatted Text from this Text Box
	Dim sText As String = "<Parameter Resolved='True' ComponentIdentifier='" & oFullFileName & "' Name='TagName' Precision='3'>""</Parameter>"

			
	'================================ Create a textbox in the Sketch to place the Iporp Tekeningnummer ====================
		 
	' Create Text With simple String As Input.  Since this doesn't use
	' any Text Overrides, it will Default To the active Text Style.
	
	' 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

	'==================== Creating an Objectcollection To be Marked ======================
	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

	'==================== Creating the Mark on the textbox  ======================

	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"

	Call ZoomAll
	
	oPartDoc.Save
	
End Sub

Sub ZoomAll
	
	' zoom all, this to be sure the part is in ISOmetrich position saved so it is ISO visible in explorer
	ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute

End Sub

 

And here is how to test and retrieve a textbox formatted text. 

Sub Main
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oFullFileName As String  = oPartDoc.FullFileName
	Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
	Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface To Place Textbox")

	Dim oSketch As PlanarSketch = oPartCompDef.Sketches.Add(oFace, True)

	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

	Dim oTextBox As Inventor.TextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(0.3, 0.5),"Hello") 

	Dim sText As String = "<Parameter Resolved='True' ComponentIdentifier='" & oFullFileName & "' Name='Tag' Precision='3'>""</Parameter>"

	oTextBox.FormattedText = sText
	
	'Retrieve formatted text from an exisiting textbox
	'RetrieveFormattedText()
End Sub

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
Message 8 of 10
jeanB99VC
in reply to: A.Acheson

Hi Allen,

 

I' m sorry but I've tried your code but it does not seem to work.

I'm using Inventor 2023 maybe that is the case I don't know.

 

Also your test does not give me the reuslt  I want.

I want to textbox to contain the Field from the Iprop not the text so I mean the field <Tekeningnummer>.

This way it updates when the field changes

See also the attached screenshots.

Message 9 of 10
jeanB99VC
in reply to: jeanB99VC

Hi There,

 

I finally figured it out. I have combined a part of the rule from another post;

How to assign a iProperty to a textbox in my title through VB

The ruleline by @WCrihfield does the trick 🙂 :

Dim sText As String
		    	sText = "<Property Document='Model' PropertySet='User Defined Properties' Property='Tekeningnummer' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}'>Tekeningnummer</Property>"

Now the "Tekeningnummer" as a Field is inserted in the textbox and I get what I want.

Many thanks to all of you, espacially mentioned @JelteDeJong and @A.Acheson 

 

For you all to use and benifit from I've pasted the Rule for engraving below.

Hope you can use it and have fun with it 🙂

Last remark is that on some faces of the sheetmetal the text is placed not right but I hope to fix this in the future. For now I can work fine with it.

 

Sub Main()

'===================== DECLERATIONS ===============================
  
 '  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

		Dim oPartCompDef As PartComponentDefinition 
			oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition
		
'===================Checking If the Custom Property has already been made in the part =================

'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. Custom Iprop Tekeningnummer will be updated", "Controle op MarkingSketch")
			
'Updating Custom IProperty with filenumber in it calling it Tekeningnummer
		
			iProperties.Value("Custom", "Tekeningnummer") = ThisDoc.FileName(False) 'false = without extension
			iProperties.Value("Custom", "Tekeningnummer") = (Left(ThisDoc.FileName(False),14))	
		
			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)	


' ===================== Create a Custom Parameter in Iproperties "Tekeningnummer"======================

		'Creating Custom IProperty with filenumber in it calling it Tekeningnummer
		
			iProperties.Value("Custom", "Tekeningnummer") = ThisDoc.FileName(False) 'false = without extension
			iProperties.Value("Custom", "Tekeningnummer") = (Left(ThisDoc.FileName(False),14))	
		
		'Creating a UserParameter Where the Tekeningnummer value Is put In
		
		Dim PropValue As String = iProperties.Value("Custom", "Tekeningnummer") 
		
		'updates the user-defined Text Parameter
		TagName = PropValue
		
	
'================================ Create a textbox in the Sketch to place the Custom Iporperty Tekeningnummer ====================
	 
		'     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 = "<Property Document='Model' PropertySet='User Defined Properties' Property='Tekeningnummer' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}'>Tekeningnummer</Property>"
		   	
			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
			dTextSize = 0.4 ' value is in cm.  equals .125 in
		Dim sTextFont As String
'			sTextFont = "SIMPLEX"
			oTextBox.FormattedText = "<StyleOverride Font = '" & sTextFont & "' FontSize = '" & dTextSize & "'>" & _
				sText & "</StyleOverride>"


'==================== Creating an Objectcollection to be Marked ======================
    Dim oSketchObjects As ObjectCollection
    	oSketchObjects = ThisApplication.TransientObjects.CreateObjectCollection
    
    ' Get all entities in the sketch
	Dim oSketchText As Inventor.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)

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

Call ZoomAll

oPartDoc.Save
End Sub

Sub ZoomAll
	
'zoom all, this to be sure the part is in ISOmetrich position saved so it is ISO visible in explorer
	ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute

End Sub

 

Message 10 of 10
n_krisch
in reply to: jeanB99VC

hej 🙂
I've started writing my own rule for the same purpose and ran into exactly the same issue as you.

How do I get iProperties into a textbox that updates with changes?
Your rule is perfect for our case, and I just needed to make a few adjustments:

Instead of custom iProperties, I'm retrieving 'Part Number' and 'Revision Number'.

Here's how the changes would look, in case anyone needs it:

sText = "<Property Document='model' FormatID='{32853F0F-3444-11d1-9E93-0060B03C1CA6}' PropertyID='5' />" & " - " & "<Property Document='model' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='9' />"


Hats off, and thanks for sharing the code!

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

Post to forums  

Autodesk Design & Make Report