Inventor Customization

Inventor Customization

Reply
Valued Contributor
Arnold82
Posts: 56
Registered: ‎12-20-2012
Message 1 of 4 (459 Views)
Accepted Solution

Rule to suppress/unsuppress many features

459 Views, 3 Replies
02-14-2013 05:14 AM

I have a code working that is not very efficient.

It works, but it is very slow, i suspect it can be 28x faster, but I don't know how

 

What I have:

I have a plate with many hole patterns.

I calculated how many holes each pattern has

Parameters: Excel_Holes_Row_0 to Excel_Holes_Row 27

 

For each Row i have 4 features:

Pipe Hole

Rectangular array of Pipe Holes

Product Hole

Rectangular array of Product holes

 

What I want to do:

I want to suppress/unsuppress features with a rule

If Excel_Holes_Row_20 < 2 It means Suppress the rectangular arrays on this row

If Excel_Holes_Row_20 = 0 It means suppress the hole features on this row

 

 

This is my code:

 

Dim oDoc As Document = ThisDoc.Document

Dim PFeats As PartFeatures = oDoc.ComponentDefinition.Features
Dim PFeat As PartFeature

For Each PFeat In PFeats

i = 0

For i = 0 To 27 Step 1
If PFeat.Name = "Pipe Hole " & i Then
If Parameter("Excel_Holes_Row_"&i) = 0 Then
PFeat.Suppressed = True
Else
PFeat.Suppressed = False
End If
End If

If PFeat.Name = "Product Hole " & i Then
If Parameter("Excel_Holes_Row_"& i ) = 0 Then
PFeat.Suppressed = True
Else
PFeat.Suppressed = False
End If
End If

If PFeat.Name = "Pipe Row " & i Then
If Parameter("Excel_Holes_Row_"& i ) < 2 Then
PFeat.Suppressed = True
Else
PFeat.Suppressed = False
End If
End If

If PFeat.Name = "Product Row " & i Then
If Parameter("Excel_Holes_Row_"& i ) < 2 Then
PFeat.Suppressed = True
Else
PFeat.Suppressed = False
End If
End If

 

 

How can I make this more efficient?

 

Thanks in advance,

 

 

Arnold

 

 

 

 

Distinguished Contributor
thomaskennedy
Posts: 112
Registered: ‎09-27-2010
Message 2 of 4 (457 Views)

Re: Rule to suppress/unsuppress many features

02-14-2013 06:51 AM in reply to: Arnold82

I've found that feature / component / constraint suppression can be extremely slow.

 

One thing you can do to improve performance is to set the End of Part to the top before you begin the feature suppresion, then set it to the bottom when you have finished.

 

This will set either the End of Part or End of Features (depending on document type) to the bottom :

 

Dim oCompDef As Inventor.ComponentDefinition
oCompDef = ThisDoc.Document.ComponentDefinition
If TypeOf oCompDef Is Inventor.AssemblyComponentDefinition Then
	oCompDef.SetEndOfFeaturesToTopOrBottom(True)
ElseIf TypeOf oCompDef Is Inventor.PartComponentDefinition Then
	oCompDef.SetEndOfPartToTopOrBottom(True)
End If

 

This will set the EOP to the bottom :

 

Dim oCompDef As Inventor.ComponentDefinition
oCompDef = ThisDoc.Document.ComponentDefinition
If TypeOf oCompDef Is Inventor.AssemblyComponentDefinition Then
	oCompDef.SetEndOfFeaturesToTopOrBottom(False)
ElseIf TypeOf oCompDef Is Inventor.PartComponentDefinition Then
	oCompDef.SetEndOfPartToTopOrBottom(False)
End If

 

Hopefully this will improve performance for you, it did for me.

 

Cheers

Tom

 

ps. There is an alternative way to control feature suppression at a part level - right click on the feature and go to properties. From there you can control if the feature is suppreseed based on the value of a Parameter, probably not the answer for your issue, but it's a good one to know.

Valued Contributor
Arnold82
Posts: 56
Registered: ‎12-20-2012
Message 3 of 4 (432 Views)

Re: Rule to suppress/unsuppress many features

02-15-2013 01:37 AM in reply to: Arnold82

 

Place End of Part at top truly helps a lot with speed

(it would normally build up each row in 2 sec (28 times)

Now its like 5-10 seconds

 

I also renamed all features with row number in front. Eg.: 20 - Pipe hole.

With Val(PFeat.Name) I get 20 as result.

Previously i check for each value from 0 to 27

 

oCompDef.SetEndOfPartToTopOrBottom(True)

For Each PFeat In PFeats


i = Val(PFeat.Name)


If PFeat.Name = i & " - Pipe Hole" Then
If Parameter("Excel_Holes_Row_"&i) = 0 Then

Placing End of Part on top does not affect dimension in drawing 

 

 

Thanks for the help

 

 

*Expert Elite*
jdkriek
Posts: 528
Registered: ‎03-29-2007
Message 4 of 4 (421 Views)

Re: Rule to suppress/unsuppress many features

02-15-2013 08:47 AM in reply to: Arnold82

Very nice, I never thought about moving the EOP. Kudos.

Jonathan D. Kriek

Autodesk Inventor Certified Expert
Microsoft Certified Application Developer
_____________________________________________________
Did I help you? Please choose Accept as Solution or Kudos below
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.