iFeature

iFeature

martinhoos
Advocate Advocate
949 Views
19 Replies
Message 1 of 20

iFeature

martinhoos
Advocate
Advocate

Hello,

i have a iFeature named LongPilot. If i insert this one time the name changed to "LongPilot:1" and the next time to "LongPilot:2". Is it possible to count the quantity of the "LongPilots"?  Possible quantitys are only:  0 or 1 or 2 of them. The amount stored in an userparameter named "amount".

One Probleme: If i insert and insert and delete and delete the Longpilots, i can have names like "LongPilot:8" or stuff like this....

Hopefully you can help me...

Regards from Germany.

Martin

 

0 Likes
Accepted solutions (2)
950 Views
19 Replies
Replies (19)
Message 2 of 20

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Again and modified a little!!

 

Public Sub features()

Dim a As Application
Set a = ThisApplication
Dim b As PartDocument
Set b = a.ActiveDocument
Dim f As Object ' ExtrudeFeature
'Set c = b.ComponentDefinition.Features

Dim i As Integer
i = 0
For Each f In b.ComponentDefinition.features
If InStr(f.Name, "LongPilot") > 0 Then
i = i + 1
End If

Next

MsgBox i
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 20

martinhoos
Advocate
Advocate

Hi Brandeneurope,

thank you for your reply... your makro runs! Is it possible for you to change the script into ilogic-code? I tried .... without result  😞

Regards Martin

 

0 Likes
Message 4 of 20

chandra.shekar.g
Autodesk Support
Autodesk Support

@martinhoos,

 

Try the following iLogic code to count LongPilot iFeature.

 

Dim b As PartDocument
b = ThisApplication.ActiveDocument

Dim i As Integer 

For Each f In b.ComponentDefinition.Features
	If f.Name.StartsWith("LongPilot")Then
		i = i + 1 
	End If
Next

MessageBox.Show("Count of LongPilot is : " & i.ToString, "iLogic")

Please feel free to contact if there is any queries,

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 20

bradeneuropeArthur
Mentor
Mentor

Yes,

 

Public Sub Main()

Dim a As Application
a = ThisApplication
Dim b As PartDocument
b = a.ActiveDocument
Dim f As Object ' ExtrudeFeature
'Set c = b.ComponentDefinition.Features

Dim i As Integer
i = 0
For Each f In b.ComponentDefinition.Features
If InStr(f.Name, "LongPilot") > 0 Then
i = i + 1
End If

Next

MsgBox (i)
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 20

bradeneuropeArthur
Mentor
Mentor

@martinhoos

Please let me know if you need further assistance....

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 20

martinhoos
Advocate
Advocate

Hi Brandeneurope,

yes i need further help.... i thought i couldt handle this by myselfe - but ..... (its to hard to understand)

 

the idea is: i have a tube which i changed which ilogic (diameter, radius, material ....) 

sometimes i need the "LongPilot", which has also a diameter. If the Name of the LongPilot is "LongPilot:1" or "LongPilot:2" i can change the diameter with:

 

iFeature.ChangeRow("LongPilot:1", "16 mm")

or

iFeature.ChangeRow("LongPilot:1", "18 mm")

But sometimes the name is, for example like, "LongPilot:5"  (delete and stored again) - so i can not identify the Name   😞

 

 

I used this code to place the LongPilot in:

Public Sub Main() 

	Dim oPartDoc As PartDocument 
	oPartDoc = ThisApplication.ActiveDocument 

	Dim oPartDef As PartComponentDefinition 
	oPartDef = oPartDoc.ComponentDefinition 

	Dim oWorkPoint As WorkPoint 
	oWorkPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPointFilter, "Select a point to place iFeature")  
	' Get the selected face to use as input for the iFeature. 
	Dim oFacePlane As WorkPlane 
	oFacePlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select a Plane to place iFeature") 

	Dim oFeatures As PartFeatures 
	oFeatures = oPartDef.Features 

	' Create an iFeatureDefinition object. 
	Dim oiFeatureDef As iFeatureDefinition 
	oiFeatureDef = oFeatures.iFeatures.CreateiFeatureDefinition("V:\Inventor-2015\1-Inventor\Catalog\KKI\LongPilot.ide")

	' Set the input. 
	Dim oInput As iFeatureInput 
	For Each oInput In oiFeatureDef.iFeatureInputs 
		Dim oParamInput As iFeatureParameterInput 
		
		Select Case oInput.Name 
		Case "Durchmesser" 
		Dim oTubeDia As iFeatureParameterInput 
		oTubeDia = oInput 
		oTubeDia.Expression = durchmesser


		Case "Skizzierebene1" 
		Dim oPlaneInput As iFeatureSketchPlaneInput 
		oPlaneInput = oInput 
		oPlaneInput.PlaneInput = oFacePlane 

		Case "Referenzpunkt1" 

		Dim oRefPoint As iFeatureEntityInput 
		oRefPoint = oInput 
		oRefPoint.Entity = oWorkPoint 

		End Select 
	Next 

	' Create the iFeature. 
	Dim oiFeature As iFeature 
	oiFeature = oFeatures.iFeatures.Add(oiFeatureDef) 

End Sub

 

Long Story short: If i changed the diameter from the tube all longpilots (max. 2) shouldt change also....  AND i need the amount of the Longpilots (you gave me the code above)

 

Hopefully you can give me support to handle the problem.... Thank you very much!

 

Regards

Martin

 

 

 

 

 

 

0 Likes
Message 8 of 20

bradeneuropeArthur
Mentor
Mentor
So if Diameter pipe change from 12 mm to 16 mm, the Pilot must also change from 12 to 16 mm. am I right?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 9 of 20

chandra.shekar.g
Autodesk Support
Autodesk Support

@martinhoos,

 

Do you need number of 16 dia tube and 12 dia tube? Also, wants to change name of LongPilot to respective diameter name?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 10 of 20

martinhoos
Advocate
Advocate

yes you are right....

0 Likes
Message 11 of 20

martinhoos
Advocate
Advocate

The Diameters are Ø10, Ø12, Ø16 and Ø18

If i changed the Diameter from Ø12 to Ø18 of the tube, the Longpilot shouldt also changes to Ø18.

 

The second is, i need the number of inserted LongPilots (0 or 1 or 2)

 

Regards Martin

0 Likes
Message 12 of 20

bradeneuropeArthur
Mentor
Mentor
Could you please upload the feature PilotHole

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 13 of 20

martinhoos
Advocate
Advocate

Hello Brandeneurope,

thanks for your reply... here is the iFeature...

Regards Martin

 

 

0 Likes
Message 14 of 20

bradeneuropeArthur
Mentor
Mentor
How is your pipe diameter parameter called?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 15 of 20

martinhoos
Advocate
Advocate

the Diameter of the pipe is called: durchmesser

 

0 Likes
Message 16 of 20

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Public Sub Main()
MsgBox 	 (Parameter.Param("durchmesser").expression)
If Parameter.Param("durchmesser").Expression = "10 mm
Call features("LongPilot", 10 mm) End If

If Parameter.Param("durchmesser").Expression = "16 mm" Then
Call features("LongPilot",
16 mm)
End If

'etc
End Sub Public Sub features(Str As String , Dia as string) Dim a As Application a = ThisApplication Dim b As PartDocument b = a.ActiveDocument Dim f As Object ' ExtrudeFeature 'Set c = b.ComponentDefinition.Features Dim i As Integer i = 0 For Each f In b.ComponentDefinition.Features If InStr(f.Name, Str) > 0 Then iFeature.ChangeRow(f.name, Dia) i = i + 1 End If Next MsgBox (f.name) MsgBox (i) End Sub

 EDIT .....................

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 17 of 20

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@martinhoos,

 

Try the following iLogic code to rename the "LongPilot" iFeature with respect to Diameter.

 

Public Sub Main()

    Dim oPartDoc As PartDocument
    oPartDoc = ThisApplication.ActiveDocument
          
    Dim oPartDef As PartComponentDefinition
    oPartDef = oPartDoc.ComponentDefinition
    
    Dim oFeatures As PartFeatures
    oFeatures = oPartDef.Features
    
    Dim i10Cnt As Integer
    Dim i12Cnt As Integer
    Dim i16Cnt As Integer
    Dim i18Cnt As Integer
    
    Dim oiFeature As iFeature
    For Each oiFeature In oFeatures.iFeatures
        If InStr(oiFeature.Name, "LongPilot") > 0 Then
            If oiFeature.Parameters.Item(8).Expression = "10 mm" Then
                i10Cnt = i10Cnt + 1
            ElseIf oiFeature.Parameters.Item(8).Expression = "12 mm" Then
                i12Cnt = i12Cnt + 1
            ElseIf oiFeature.Parameters.Item(8).Expression = "16 mm" Then
                i16Cnt = i16Cnt + 1
            ElseIf oiFeature.Parameters.Item(8).Expression = "18 mm" Then
                i18Cnt = i18Cnt + 1
            End If
        End If
    Next
    
    Dim i As Integer
    If i10Cnt > 0 Then
        For i = 1 To i10Cnt
            For Each oiFeature In oFeatures.iFeatures
                If InStr(oiFeature.Name, "LongPilot") > 0 Then
                    If oiFeature.Parameters.Item(8).Expression = "10 mm" Then
                        If oiFeature.Name = "LongPilot Dia 10 mm :" & i - 1 Then
                             GoTo NextIteration10
                        End If
                        If Not InStr(oiFeature.Name, "LongPilot Dia 10 mm :") > 0 Then
                            oiFeature.Name = "LongPilot Dia 10 mm :" & i-1
                            GoTo NextIteration10
                        End If
                    End If
                End If
            Next
NextIteration10:
        Next
    End If
    If i12Cnt > 0 Then
        For i = 1 To i12Cnt
            For Each oiFeature In oFeatures.iFeatures
                If InStr(oiFeature.Name, "LongPilot") > 0 Then
                    If oiFeature.Parameters.Item(8).Expression = "12 mm" Then
                        If oiFeature.Name = "LongPilot Dia 12 mm :" & i -1 Then
                             GoTo NextIteration12
                        End If
                        If Not InStr(oiFeature.Name, "LongPilot Dia 12 mm :") > 0 Then
                            oiFeature.Name = "LongPilot Dia 12 mm :" & i -1
                            GoTo NextIteration12
                        End If
                    End If
                End If
            Next
NextIteration12:
        Next
    End If
    If i16Cnt > 0 Then
        For i = 1 To i16Cnt
            For Each oiFeature In oFeatures.iFeatures
                If InStr(oiFeature.Name, "LongPilot") > 0 Then
                    If oiFeature.Parameters.Item(8).Expression = "16 mm" Then
                        If oiFeature.Name = "LongPilot Dia 16 mm :" & i -1Then
                             GoTo NextIteration16
                        End If
                        If Not InStr(oiFeature.Name, "LongPilot Dia 16 mm :") > 0 Then
                            oiFeature.Name = "LongPilot Dia 16 mm :" & i -1
                            GoTo NextIteration16
                        End If
                    End If
                End If
            Next
NextIteration16:
        Next
    End If
    If i18Cnt > 0 Then
        For i = 1 To i18Cnt
            For Each oiFeature In oFeatures.iFeatures
                If InStr(oiFeature.Name, "LongPilot") > 0 Then
                    If oiFeature.Parameters.Item(8).Expression = "18 mm" Then
                        If oiFeature.Name = "LongPilot Dia 18 mm :" & i - 1 Then
                             GoTo NextIteration18
                        End If
                        If Not InStr(oiFeature.Name, "LongPilot Dia 18 mm :") > 0 Then
                            oiFeature.Name = "LongPilot Dia 18 mm :" & i - 1
                            GoTo NextIteration18
                        End If
                    End If
                End If
            Next
NextIteration18:
        Next
    End If

End Sub

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 18 of 20

bradeneuropeArthur
Mentor
Mentor
Please let me know if you need assistance.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 19 of 20

martinhoos
Advocate
Advocate

Hello Brandeneurope,

Thank you very much ... this is what i needed!  Great work.

Regards Martin

 

 

0 Likes
Message 20 of 20

martinhoos
Advocate
Advocate

Hello Chandra,

thank you very much for your help - also your code helps me to solve my Problem.

Regards Martin

0 Likes