News: HyperSizer.com has a Community Board and Customer Support System. Submit a ticket at http://hypersizer.com/ticket

Author Topic: Error getting access to a component's AnalysisSelections  (Read 2377 times)

danvic

  • Client
  • **
  • Posts: 7
    •  
Error getting access to a component's AnalysisSelections
« on: February 28, 2019, 11:41:53 AM »

Hi,

I'm trying to add code to access a component's analysisSelections object and update the buckling criteria for one of its objects (an open span for instance). The whole process to assign the single bpcZBonded concept to an assembly and its group is verified to work opening the Hypersizer GUI.

The error mentions family 4 (bpfUniaxialStiffenedPanelFamily) and a BeamPanelConcept 21 (bpcIBonded) that is not the assigned concept.

Here is a VBA pseudo-code for what I've been doing:

Code: [Select]
Dim bpcBeamPanelConceptList(0 To 0) As HyperSizer.BeamPanelConcept
bpcBeamPanelConceptList(0) = 23 'bpcZBonded
Call objGroup.setConcepts(bpcBeamPanelConceptList())
Call objGroup.SetGroupMembership(lngComponentIds)
objGroup.Save
' (assign lngComponentIds to assembly using objAssembly.ComponentIds.Add (not shown)
Dim selections As HyperSizer.AnalysisSelectionCol
Dim selection As HyperSizer.analysisSelection
Set objComponent = objProject.components.GetComponent(lngComponentId)
'lngComponentId is part of lngComponentIds
Set selections = objComponent.AnalysisSelections

The last line of code above generates the error.

Does anyone know what I could be doing wrong? Any reference to a working VBA code doing something similar would help. The sample python code from the documentation is the one I'm adapting to VBA here.

Thanks!

August

  • Administrator
  • *****
  • Posts: 15
    •  
Re: Error getting access to a component's AnalysisSelections
« Reply #1 on: February 28, 2019, 12:31:18 PM »
Hello,

I was not able to replicate the issue you're having. Hard to say what the exact cause is from your code snippet, but it seems like something could be going wrong in the component or group setup.

I recommend to avoid assigning multiple components to groups unless absolutely necessary. By default, HyperSizer creates 1 group per component. Usually the only reason to deviate from this pattern is if you are doing variable linking between components.

So instead of assigning the components to a group, use the Component.GroupID property to get the group corresponding to that component, and then do your group modifications.

Here is a snippet of code where I successfully pulled the AnalysisSelections from the component.

If you're still having trouble, perhaps we could take a look at your full VBA code and database.

Code: [Select]
' Get project object
Set oProject = oHS.Projects.GetProject("Test Project")

' Get the component
Dim comp As HyperSizer.Component
Dim selections As HyperSizer.AnalysisSelectionCol
Set comp = oProject.Components.GetComponent(2)

' Get the group
Dim group As HyperSizer.group
Set group = oProject.Groups.GetGroup(comp.GroupId)

' Set the concept
Dim bpcBeamPanelConceptList(0 To 0) As HyperSizer.BeamPanelConcept
bpcBeamPanelConceptList(0) = 23 'bpcZBonded
Call group.setConcepts(bpcBeamPanelConceptList())
group.Save

' Get the analysis selections
Set selections = comp.AnalysisSelections

danvic

  • Client
  • **
  • Posts: 7
    •  
Re: Error getting access to a component's AnalysisSelections
« Reply #2 on: February 28, 2019, 12:58:50 PM »
Unfortunately I had to use variable linking (by associating multiple components to a single group id), since a shared stringer spacing is required in this project.

Thanks for pointing that this could be the issue - I'll see what I can do and open a ticket if necessary (providing a more detailed code and database).