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: 

disable parameters when part is supressed... or?

10 REPLIES 10
Reply
Message 1 of 11
LSA-skan
562 Views, 10 Replies

disable parameters when part is supressed... or?

Hi All

 

I have a configurator assy, which is controlled with an iLogic rule.

one of the parts is being changed in a lot of ways according to the different configurations. But in one of the Configurations the part must be supressed, which works fine, however next time i run the rule i get an error message from all the other instances where it would change a parameter if the part was active.

 

I have tried adding if [the configuration that makes the part supressed] = False then, in the beginning of the the code that fails, to simply prevent it from running, but it still makes an error.

 

and as you can see i have a lot of lines where the part normally would be configurated..

 

Error on Line 628 : Method arguments must be enclosed in parentheses.
Error on Line 629 : Method arguments must be enclosed in parentheses.
Error on Line 633 : Method arguments must be enclosed in parentheses.
Error on Line 634 : Method arguments must be enclosed in parentheses.
Error on Line 637 : Method arguments must be enclosed in parentheses.
Error on Line 642 : Method arguments must be enclosed in parentheses.
Error on Line 643 : Method arguments must be enclosed in parentheses.
Error on Line 646 : Method arguments must be enclosed in parentheses.
Error on Line 647 : Method arguments must be enclosed in parentheses.
Error on Line 649 : Method arguments must be enclosed in parentheses.
Error on Line 654 : Method arguments must be enclosed in parentheses.
Error on Line 656 : Method arguments must be enclosed in parentheses.
Error on Line 673 : Method arguments must be enclosed in parentheses.
Error on Line 678 : Method arguments must be enclosed in parentheses.
Error on Line 679 : Method arguments must be enclosed in parentheses.
Error on Line 682 : Method arguments must be enclosed in parentheses.
Error on Line 683 : Method arguments must be enclosed in parentheses.
Error on Line 686 : Method arguments must be enclosed in parentheses.
Error on Line 687 : Method arguments must be enclosed in parentheses.
Error on Line 690 : Method arguments must be enclosed in parentheses.
Error on Line 691 : Method arguments must be enclosed in parentheses.
Error on Line 694 : Method arguments must be enclosed in parentheses.
Error on Line 695 : Method arguments must be enclosed in parentheses.
Error on Line 698 : Method arguments must be enclosed in parentheses.
Error on Line 699 : Method arguments must be enclosed in parentheses.
Error on Line 702 : Method arguments must be enclosed in parentheses.
Error on Line 703 : Method arguments must be enclosed in parentheses.
Error on Line 709 : Method arguments must be enclosed in parentheses.
Error on Line 714 : Method arguments must be enclosed in parentheses.
Error on Line 724 : Method arguments must be enclosed in parentheses.
Error on Line 729 : Method arguments must be enclosed in parentheses.
Error on Line 739 : Method arguments must be enclosed in parentheses.
Error on Line 744 : Method arguments must be enclosed in parentheses.
Error on Line 754 : Method arguments must be enclosed in parentheses.
Error on Line 759 : Method arguments must be enclosed in parentheses.
Error on Line 776 : Method arguments must be enclosed in parentheses.
Error on Line 777 : Method arguments must be enclosed in parentheses.
Error on Line 780 : Method arguments must be enclosed in parentheses.
Error on Line 781 : Method arguments must be enclosed in parentheses.
Error on Line 784 : Method arguments must be enclosed in parentheses.
Error on Line 785 : Method arguments must be enclosed in parentheses.
Error on Line 788 : Method arguments must be enclosed in parentheses.
Error on Line 789 : Method arguments must be enclosed in parentheses.
Error on Line 792 : Method arguments must be enclosed in parentheses.
Error on Line 793 : Method arguments must be enclosed in parentheses.
Error on Line 796 : Method arguments must be enclosed in parentheses.
Error on Line 797 : Method arguments must be enclosed in parentheses.
Error on Line 877 : Method arguments must be enclosed in parentheses.
Error on Line 878 : Method arguments must be enclosed in parentheses.
Error on Line 943 : Method arguments must be enclosed in parentheses.
Error on Line 944 : Method arguments must be enclosed in parentheses.
Error on Line 947 : Method arguments must be enclosed in parentheses.
Error on Line 948 : Method arguments must be enclosed in parentheses.
Error on Line 953 : Method arguments must be enclosed in parentheses.
Error on Line 954 : Method arguments must be enclosed in parentheses.
Error on Line 957 : Method arguments must be enclosed in parentheses.
Error on Line 958 : Method arguments must be enclosed in parentheses.
Error on Line 964 : Method arguments must be enclosed in parentheses.
Error on Line 965 : Method arguments must be enclosed in parentheses.
Error on Line 968 : Method arguments must be enclosed in parentheses.
Error on Line 969 : Method arguments must be enclosed in parentheses.
Error on Line 974 : Method arguments must be enclosed in parentheses.
Error on Line 975 : Method arguments must be enclosed in parentheses.
Error on Line 978 : Method arguments must be enclosed in parentheses.
Error on Line 979 : Method arguments must be enclosed in parentheses.
Error on Line 982 : Method arguments must be enclosed in parentheses.
Error on Line 983 : Method arguments must be enclosed in parentheses.
Error on Line 986 : Method arguments must be enclosed in parentheses.
Error on Line 987 : Method arguments must be enclosed in parentheses.
Error on Line 990 : Method arguments must be enclosed in parentheses.
Error on Line 991 : Method arguments must be enclosed in parentheses.
Error on Line 997 : Method arguments must be enclosed in parentheses.
Error on Line 998 : Method arguments must be enclosed in parentheses.
Error on Line 1001 : Method arguments must be enclosed in parentheses.
Error on Line 1002 : Method arguments must be enclosed in parentheses.
Error on Line 1005 : Method arguments must be enclosed in parentheses.
Error on Line 1006 : Method arguments must be enclosed in parentheses.
Error on Line 1009 : Method arguments must be enclosed in parentheses.
Error on Line 1010 : Method arguments must be enclosed in parentheses.
Error on Line 1013 : Method arguments must be enclosed in parentheses.
Error on Line 1014 : Method arguments must be enclosed in parentheses.
Error on Line 1019 : Method arguments must be enclosed in parentheses.
Error on Line 1020 : Method arguments must be enclosed in parentheses.
Error on Line 1022 : Method arguments must be enclosed in parentheses.
Error on Line 1023 : Method arguments must be enclosed in parentheses.
Error on Line 1028 : Method arguments must be enclosed in parentheses.
Error on Line 1029 : Method arguments must be enclosed in parentheses.
Error on Line 1031 : Method arguments must be enclosed in parentheses.
Error on Line 1032 : Method arguments must be enclosed in parentheses.
Error on Line 1039 : Method arguments must be enclosed in parentheses.
Error on Line 1040 : Method arguments must be enclosed in parentheses.
Error on Line 1042 : Method arguments must be enclosed in parentheses.
Error on Line 1043 : Method arguments must be enclosed in parentheses.
Error on Line 1050 : Method arguments must be enclosed in parentheses.
Error on Line 1051 : Method arguments must be enclosed in parentheses.
Error on Line 1053 : Method arguments must be enclosed in parentheses.
Error on Line 1054 : Method arguments must be enclosed in parentheses.
Error on Line 1059 : Method arguments must be enclosed in parentheses.
Error on Line 1060 : Method arguments must be enclosed in parentheses.
Error on Line 1062 : Method arguments must be enclosed in parentheses.
Error on Line 1063 : Method arguments must be enclosed in parentheses.
Error on Line 0 : Maximum number of errors has been exceeded.

 

I don't understand how to enclose the argument in parentheses..

 

hope some knows a trick to bypass/Disable these lines...

 

/LSA-Skan

10 REPLIES 10
Message 2 of 11
xiaodong_liang
in reply to: LSA-skan

hi,

 

hope the code below self explained your question:

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOcc As ComponentOccurrence

	For Each oOcc In oAsmCompDef.Occurrences
		Dim oName As String
		oName = oOcc.Name
		
 		oOcc.Suppress (True)  
		'the argument is SkipDocumentSave, in default it is false.
		' so you can also write as
		'oOcc.Suppress()
		 
	Next

 

Message 3 of 11
LSA-skan
in reply to: xiaodong_liang

Hi Xiaodong Liang

 

Thanks for the reply.. 🙂

 

I will try this, i´ll be back with a result 🙂

 

/LSA-Skan

Message 4 of 11
LSA-skan
in reply to: xiaodong_liang

Hi Xiaodong Liang

 

Sorry for the late response, i was put on another project, and had to pause this.

 

I have now tried to use your code, but im affraid my rookie skills is not sufficient, to make it work as i want to.

 

First i tried to paste it in the beginning of my code to see what happend, and i just supressed the first part in the browser.

 

Then i tried pasting the code to within the IF sentence making the problems, leaving the Dim's at the beginning.

 

This supressed my entire assy.

 

can you maybe help me specify how and where to paste the code..?

 

/LSA-skan

Message 5 of 11
jddickson
in reply to: LSA-skan

If you want you can post the code on here and I will try to fix it for you. A lot of our code deals with suppressing features and part. I think I might be able to help.

 

Thanks

JD

Message 6 of 11
LSA-skan
in reply to: jddickson

Hi JD

 

The code is fairly long, 1600 lines or so, and many of the variables is in danish, and might not have any meaning to you.. :), but i have tried to narrow it down to what i think is enough for you to help me.. 🙂

 

If sekskant = True Then
	booleanseks = InputRadioBox("Udvendig eller indvendig", "Lejehus med Udvendig ", "Lejehus med Indvendig", booleanseks, Title := "6-kant type")
		If booleanseks = True Then
		Component.Replace("kombihus:1", "M:\tegn\Standard bibliotek\90000 Indkøbt standard\90093.ipt", True)
		Component.IsActive("Rulle-2:1") = False
		End If
		If booleanseks = False Then
		Component.Replace("kombihus:1", "M:\tegn\Standard bibliotek\90000 Indkøbt standard\90092.ipt", True)
		Component.IsActive("Rulle-2:1") = True
		Rulle-2.ipt.ADiameter = "15"
		Rulle-2.ipt.Sekskant = True
		Constraint.IsActive("LejeAksel:1") = False
		Constraint.IsActive("LejeAksel:2") = False
		Constraint.IsActive("Sekskant:1") = True
		Constraint.IsActive("Sekskant:2") = True
		End If
	End If
Else
Rulle-2.ipt.Sekskant = False
Component.IsActive("Rulle-2:1") = True
Constraint.IsActive("LejeAksel:1") = True
Constraint.IsActive("LejeAksel:2") = True
Constraint.IsActive("Sekskant:1") = False
Constraint.IsActive("Sekskant:2") = False
End If

 This is the part of the code i use to supress my part (Rulle-2:1) and this part is normally being altered in many diffrent ways, but in this case it needs to be supressed. which works ok, but i get an error message, and when i wanna make a new configuration it will not unsupress the part again... and i have to do it manually even though i put this at the top of the code. I have attached a picture of the error im getting. "Fatal error"

Component.IsActive("Rulle-2:1") = True
Message 7 of 11
xiaodong_liang
in reply to: LSA-skan

Hi LSA-skan,

 

it is still hard to jump into with the information you provided. Could you try to create a simplest assembly, adding with some parts to build a reproducible scenario? In addition, please do try t isolate your rule till it can occur. By these, it can be helpful to any peer to offer a hand. I understand it is a bit hard to isolate, but addressing your problem is more important.

Message 8 of 11
LSA-skan
in reply to: xiaodong_liang

Hi Xiaodong Liang

 

Im pretty sure that if i make a simple assembly, the problem would not occur... as the supressing function itself shouldn't be  that complicated, so my guess is that it´s something small some place else in the code making thie issue... (up to 2600 lines now)

 

I will try to disable parts of the code till i find the bit that is causing the problem. then i can post again... and maybe you guys can help me solve it.. 🙂

 

/LSA 

Message 9 of 11
xiaodong_liang
in reply to: LSA-skan

So, if this occurs with specific dataset, it is also important to provide a copy. Thanks.

Message 10 of 11
jddickson
in reply to: LSA-skan

I’m sorry things have been out of control around here (Super busy). I still haven’t had a chance to look this over. Sorry for that will try to look at it soon.  I thought some of this code might be helpful to you.

 

This will delete all suppressed parts in the assembly. If you don’t want a new level of detail I would suggest turning off the Visibility and using the code below it.

----------------------------------------------------------------------------------------------------------------------------------------------------------- 

oAsmDoc = ThisDoc.Document

oCompDef = oAsmDoc.ComponentDefinition

Dim oCompOcc As ComponentOccurrence

    'Find all occurrences

    For Each oCompOcc In oCompDef.Occurrences

        'If the occurrence is a part and suppressed, delete it

        If oCompOcc.DefinitionDocumentType = kPartDocumentObject And oCompOcc.suppressed = False Then

            oCompOcc.Delete

        End If

    Next

-----------------------------------------------------------------------------------------------------------------------------------------------------------

oAsmDoc = ThisDoc.Document

oCompDef = oAsmDoc.ComponentDefinition

Dim oCompOcc As ComponentOccurrence

    'Find all occurrences

    For Each oCompOcc In oCompDef.Occurrences

        'If the occurrence is a part and Invisible, delete it

        If oCompOcc.DefinitionDocumentType = kPartDocumentObject And oCompOcc.Visible = False Then

            oCompOcc.Delete

        End If

    Next

----------------------------------------------------------------------------------------------------------------------------------------------------------- 

If you want to delete features in a part I would suggest using this code:

 

oDoc = ThisApplication.ActiveDocument

                Dim oFeatures As PartFeatures

                oFeatures = oDoc.ComponentDefinition.Features

                Dim oFeature As PartFeature

 

                                'Remove suppressed features

                                For Each oFeature In oFeatures

                                                featureName = oFeature.Name

                                                                If Not Feature.IsActive(featureName) Then

                                                                                oFeature.Delete

                                                                End If

                                Next

 

I hope some of this might help a little bit. I will try to look at your code soon.

Thanks

JD

Message 11 of 11
jddickson
in reply to: jddickson

This code below will make all invisible part reference so they will not show up in your drawing or your BOM. This might help with any constraining errors because the part is not suppressed. You would just have to change your code from suppressing parts to turning off the visibility. I hope some of this might help…

 

' set a reference to the assembly component definintion.

' This assumes an assembly document is open.

    Dim oAsmCompDef As AssemblyComponentDefinition

    oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

 

'Iterate through all of the occurrences

    Dim oOccurrence As ComponentOccurrence

    For Each oOccurrence In oAsmCompDef.Occurrences

'check for and skip virtual components

    If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then

        'set BOM as default if the component is visible

            If Component.Visible(oOccurrence.Name) = True Then

            Component.InventorComponent(oOccurrence.Name).BOMStructure = _

            BOMStructureEnum.kDefaultBOMStructure

        'set BOM as reference if the component is not visible

            ElseIf Component.Visible(oOccurrence.Name) = False Then

            Component.InventorComponent(oOccurrence.Name).BOMStructure = _

            BOMStructureEnum.kReferenceBOMStructure

            End If

    Else

    End If

    Next

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

Post to forums  

Autodesk Design & Make Report