Updating Assembly with iLogic rule problems

Updating Assembly with iLogic rule problems

ballenZXFHH
Enthusiast Enthusiast
376 Views
5 Replies
Message 1 of 6

Updating Assembly with iLogic rule problems

ballenZXFHH
Enthusiast
Enthusiast

I have an assembly that I have been working on and has been working fine so far through all the parts I have added until now. as soon as I add another part the Ilogic rule (that I got from the internet) doesn't work right. In the screencast I show how I add Pc# 12 and it gives me the error. its not just this part, its anything I try to add. Any help would be great.  This is the link to a screencast I made of my problem.        Screencast

 

Public Sub Main()

	CopyUserParams()

End Sub



Private Sub CopyUserParams()

    If ThisDoc.Document.DocumentType <> Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then

        MsgBox("The active document must be an assembly.")

        Return

    End If



    Dim asmDoc As Inventor.AssemblyDocument = ThisDoc.Document	

    For Each refDoc As Inventor.Document In asmDoc.AllReferencedDocuments

        ' Look for part documents.

        If refDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then

            Dim partDoc As Inventor.PartDocument = refDoc

            Dim refDocUserParams As UserParameters = partDoc.ComponentDefinition.Parameters.UserParameters



            ' Add the assembly parameters to the part.

            For Each asmUserParam As UserParameter In asmDoc.ComponentDefinition.Parameters.UserParameters

                ' Check to see if the parameter already exists.

                Dim checkParam As UserParameter = Nothing

                Try

                    checkParam = refDocUserParams.Item(asmUserParam.Name)

                Catch ex As Exception

                    checkParam = Nothing

                End Try



                If checkParam Is Nothing Then

                    ' Create the missing parameter.

                    refDocUserParams.AddByExpression(asmUserParam.Name, asmUserParam.Expression, asmUserParam.Units)

                Else

                    ' Update the value of the existing parameter.

                    checkParam.Expression = asmUserParam.Expression

                End If

            Next

        End If

    Next

	

	

	iLogicVb.UpdateWhenDone = True



End Sub

 

 

 

 
 
 
0 Likes
377 Views
5 Replies
Replies (5)
Message 2 of 6

Yadow
Enthusiast
Enthusiast

Hi,

I may be dumb here, but what userparameters does the placed symbol have? Maybe you need to re-define some UserParams in the part before running the code.

0 Likes
Message 3 of 6

ballenZXFHH
Enthusiast
Enthusiast

Parameters match exactly across the part and the assembly. I can put in just a simple part with no user parameters and get the same error.

0 Likes
Message 4 of 6

BDCollett
Advisor
Advisor

I wonder if it is related to an active Model State causing the error? Just a guess.

 

0 Likes
Message 5 of 6

ballenZXFHH
Enthusiast
Enthusiast

Sorry, but I'm not sure what you mean by that

0 Likes
Message 6 of 6

johnsonshiue
Community Manager
Community Manager

Hi! If you create a brand new part, does it work? It seems to work for me. Maybe the part is a CC part or a library part, which is readonly. Please share the file you downloaded. Forum experts can help take a look.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes