Suppress Flat Pattern Feature using iLogic

Suppress Flat Pattern Feature using iLogic

Anonymous
Not applicable
1,413 Views
8 Replies
Message 1 of 9

Suppress Flat Pattern Feature using iLogic

Anonymous
Not applicable

I have two features within my flat pattern (Extrusion1 & Extrusion2) and I'd like to be able to suppress one or the other using iLogic.

 

I came across this link, which is quite useful when wanting to suppress or unsuppress features as a group:

https://www.cadlinecommunity.co.uk/hc/en-us/articles/201893522-iLogic-for-Flat-Pattern-Features-in-I...

 

However I just want to do this on an individual basis

For example :

 

If hinge = 0 Then

Feature.IsActive("Extrusion1") = True

Feature.IsActive("Extrusion2") = False

 

ElseIf hinge = 1 Then

Feature.IsActive("Extrusion1") = False

Feature.IsActive("Extrusion2") = True

 

End If

 

How would I change this to alter the flat pattern features instead?

 

0 Likes
1,414 Views
8 Replies
Replies (8)
Message 2 of 9

Owner2229
Advisor
Advisor

Hi, maybe something like this?

 

 

' Get the document's definition
Dim oDoc As Document = ThisApplication.ActiveDocument Dim oSMCD As SheetMetalComponentDefinition = oDoc.ComponentDefinition Dim oFlatFeatures As FlatPatternFeatures = oSMDef.FlatPattern.Features

' Get the hinge Dim Active1 As Boolean
If hinge = 0 Then
Active1 = True
ElseIf hinge = 1 Then
Active1 = False
End If

' Suppres features ("not" before "Active1" is negating it)
Try
oFlatFeatures.Item("Extrusion1").Suppresed = Not Active1
oFlatFeatures.Item("Extrusion2").Suppresed = Active1
Catch
End Try

 

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 9

Anonymous
Not applicable

Get the following error, sorry I'm not too good with code. What should I declare this as?

 

Error on Line 4 : 'oSMDef' is not declared. It may be inaccessible due to its protection level.

0 Likes
Message 4 of 9

Owner2229
Advisor
Advisor

Sorry, I made a misstake, try it now:

 

' Get the document's definition
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSMCD As SheetMetalComponentDefinition = oDoc.ComponentDefinition
Dim oFlatFeatures As FlatPatternFeatures = oSMCD.FlatPattern.Features
' Get the hinge Dim Active1 As Boolean If hinge = 0 Then Active1 = True ElseIf hinge = 1 Then Active1 = False End If ' Suppres features ("not" before "Active1" is negating it) Try oFlatFeatures.Item("Extrusion1").Suppresed = Not Active1 oFlatFeatures.Item("Extrusion2").Suppresed = Active1 Catch End Try
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 5 of 9

Anonymous
Not applicable

Gives this error:

 

Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

0 Likes
Message 6 of 9

Owner2229
Advisor
Advisor

Well, it seems you can't use "Feature.IsActive" or ".Suppres" for FlatPattern features, so we have to add them to collections:

 

On Error Resume Next
' Get the document's definition
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSMCD As SheetMetalComponentDefinition = oDoc.ComponentDefinition
Dim oFlatFeatures As FlatPatternFeatures = oSMCD.FlatPattern.Features

' Create suppress collections:
' oColOne is for features UnSuppressed If "hinge = 0"
' oColTwo is for features Suppressed If "hinge = 0"
Dim oColOne As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oColTwo As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

' Add features to collections
oColOne.Add(oFlatFeatures.Item("Extrusion1"))
oColTwo.Add(oFlatFeatures.Item("Extrusion2"))

' Get the hinge and suppress features
If hinge = 0 Then
    oSMCD.FlatPattern.UnSuppressFeatures(oColOne)
    oSMCD.FlatPattern.SuppressFeatures(oColTwo)
ElseIf hinge = 1 Then
    oSMCD.FlatPattern.SuppressFeatures(oColOne)
    oSMCD.FlatPattern.UnSuppressFeatures(oColTwo)
End If
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 7 of 9

Anonymous
Not applicable

I had to change a couple of things to get it working. Line 1 of your code seemed to just be skipping the error with no effect.

 

This was the code I ended up arriving at:


' Get the document's definition
Dim oDoc As PartDocument
oDoc = ThisDoc.Document

Dim oSMCD As SheetMetalComponentDefinition
oSMCD = oDoc.ComponentDefinition

Dim oFlatFeatures As FlatPatternFeatures
oFlatFeatures = oSMCD.FlatPattern.Features

'Define all the features you want to work with
Dim oExtrudeFeature1 As ExtrudeFeature = oFlatFeatures.Item("Extrusion1")
Dim oExtrudeFeature2 As ExtrudeFeature = oFlatFeatures.Item("Extrusion2")

'Create object collection 1
Dim oColOne As ObjectCollection =
ThisApplication.TransientObjects.CreateObjectCollection

'Create object collection 2
Dim oColTwo As ObjectCollection =
ThisApplication.TransientObjects.CreateObjectCollection

' Add features to collections
oColOne.Add(oExtrudeFeature1)
oColTwo.Add(oExtrudeFeature2)

Try
If Parameter ("hinge") = 0 Then
' Suppress collection 2 & UnSuppress collection 1
oSMCD.FlatPattern.UnSuppressFeatures(oColOne)
oSMCD.FlatPattern.SuppressFeatures(oColTwo)

ElseIf Parameter ("hinge") = 1 Then
' UnSuppress collection 2 & Suppress collection 1
oSMCD.FlatPattern.SuppressFeatures(oColOne)
oSMCD.FlatPattern.UnSuppressFeatures(oColTwo)

End If
Catch
End Try

 

Message 8 of 9

wolfgang_nickl
Advocate
Advocate

Hello together,

 

I'm searching for another solution and studied your example.

It will work if you use Suppressed  instead of Suppresed:

 

' Get the document's definition
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSMCD As SheetMetalComponentDefinition = oDoc.ComponentDefinition
Dim oFlatFeatures As FlatPatternFeatures = oSMCD.FlatPattern.Features

' Get the hinge
Dim Active1 As Boolean
If hinge = 0 Then
    Active1 = True
ElseIf hinge = 1 Then
Active1 = False End If ' Suppres features ("not" before "Active1" is negating it) Try oFlatFeatures.Item("Extrusion1").Suppressed = Not Active1 oFlatFeatures.Item("Extrusion2").Suppressed = Active1 Catch End Try

 

Best Regards

Wolfgang

0 Likes
Message 9 of 9

klaashaesen
Contributor
Contributor

I have been trying to figure out how to disable features in the flat pattern for some time.

Finally I found this post. Your code does the trick.

Thanks

0 Likes