Create a New Visible Faces Simplified Assembly

Creator
Creator

I have tried to understand simplified assemblies and I have been able to use the AddModel procedure when an assembly does not already have a simplidied assembly but I cannot get the AddVisible procedure to work.

 

I've tried to follow http://support.industrysoftware.automation.siemens.com/training/se/106/api/SolidEdgeAssembly~Simplif...

 

The problem with this example is that it requires a SimplifiedAssembly to already exist (Item(1)), when there isn't one then you can't initiate the SimplifiedAssembly object to call AddVisible. I get an error from the application.

 

objSimpAss = objSimpAssys.Item(1)
            objSimpAss = objSimpAssys.AddVisible(0, m_ExcludeOccurencies, 0, 1, m_IncludeOccurencies, 0)

m_ExcludeOccurrencies is an empty array

m_IncludeOccurrencies is an array of all top level occurrencies

 

Can anyone offer any advice?

6 REPLIES

Re: Create a New Visible Faces Simplified Assembly

Creator
Creator

As an update I am managing to get the first SimplifiedAssembly if, and only if, I stop the code at the line objSimpAss = objSimpAssys.Item(1), expand the objSimpAssys in the Watch window and then continue with the code.

 

Can anyone explain this?

Re: Create a New Visible Faces Simplified Assembly

Creator
Creator

The software still throws an exception during AddVisible....

Re: Create a New Visible Faces Simplified Assembly

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Reading through your description, I think you may have some points wrong. I'll try to explain.

 

The problem with this example is that it requires a SimplifiedAssembly to already exist (Item(1)), when there isn't one then you can't initiate the SimplifiedAssembly object to call AddVisible.

The AddVisible property is a member of the SimplifiedAssemblies Collection, not the SimplifiedAssembly Object. That said, you do not need an existing SimplifiedAssembly to add a new one.

 

I have not tried coding this myself but it would seem that you should be able to:

  • Create a new Assembly
  • Call Assembly.Occurrences.Add() to add a new occurrence to an existing document.
  • Create the OccurrenceExclude and OccurrenceInclude arrays. OccurrenceInclude will contain the previously added occurrence.
  • Call Assembly.SimplifiedAssemblies.AddVisible()

Again, I haven't tried this myself but this is the workflow that I'm seeing that should work.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Create a New Visible Faces Simplified Assembly

Creator
Creator

The problem I was seeing was that the AddVisible method, which I am using against the SimplifiedAssemblies, has to write its output to a variable. From the examples I'd believed that this variable had to be one of the SimplifiedAssembly objects contained in the SimplifiedAssemblies collection.

 

After reading your reply it made me think and I simply wrote the answer to a new variable...and it worked.

'Collect the simplified assemblies collection
objAsmDoc = objApplication.ActiveDocument
objSimpls = objAsmDoc.SimplifiedAssemblies
'Add just one item to the include array, this is all that is needed
arrayIncludeOccs(0) = objAsmDoc.Occurrences.Item(1)
'Add Visible faces
objSimpl = objSimpls.AddVisible(0, arrayExcludeOccs, 0, 1, arrayIncludeOccs, 2)

 Thank you for the feedback.

Re: Create a New Visible Faces Simplified Assembly

Creator
Creator

I'm almost there but seem to be having a strange problem.

 

When run the first time the process doesn;t appear to complete, right clicking on the SimplifiedAssembly in Solid Edge provides the menu options to Edit, Update, Delete but Hide, Show and Show All or greyed out.

 

If I select Edit, then Finish the options are avialable again.

 

If I then delete the Simplified Assembly and re-run the procedure it completes with all the right click options available.

 

I've tried applying the Edit method of SimplifiedAssembly as well as the Update method. I've tried updaing the document and also to set the value of ActivateSimplifiedAssembly to false but none of this eems to work.

 

Looking at the cusor image in Solid Edge it is almost as if it still waiting for a selection.

Re: Create a New Visible Faces Simplified Assembly

Creator
Creator

Finally solved it Smiley Very Happy

 

For the AddVisibleFaces method to work fully the application must be in Simplify mode, so I downloaded and ran Spy for Solid Edge to get the command ID and then called tha command before the method:

 

'Create the visible faces simplified model
            objSimpAssys = Me.ToolAssembly.SimplifiedAssemblies

            'Develop the exclude and include arrays, exclude to be empty, include to have all the occurrences
            MessageBox.Show("Identifying Occurrences")
            Dim arrayExcludeOccs(0) As Object
            Dim arrayIncludeOccs(Me.ToolAssembly.Occurrences.Count) As Object

            For iCount As Integer = 1 To Me.ToolAssembly.Occurrences.Count
                arrayIncludeOccs(iCount - 1) = Me.ToolAssembly.Occurrences.Item(iCount)
            Next

            'Create the simplified assembly
            MessageBox.Show("Starting Simplified")
            Me.ToolAssembly.Application.StartCommand(33146)
            Me.ToolAssembly.Application.DoIdle()
            objSimpAss = objSimpAssys.AddVisible(0, arrayExcludeOccs, 0.01, Me.ToolAssembly.Occurrences.Count, _
                                                    arrayIncludeOccs, 2)