News: Contact us to upgrade your software!

Author Topic: Visual Basic/COM interface questions  (Read 23460 times)

JEA

  • Client
  • **
  • Posts: 12
    •  
Visual Basic/COM interface questions
« on: June 18, 2009, 08:02:18 AM »
I am working with Visual Basic to control HyperSizer and extract results, following the object model training examples.

I am currently trying to go through extracting results, and have a few questions (I am not very good at VB, learning as I go)

When extracting what concept was used for a given group/component, I am using:
Component_Object.ResultPanel(pcrConcept)

This is returning a number instead of the name of the concept.  Is there a different tool that returns the name of the concept selected/used?  IF not, does the concept number align with the concepts tab in HyperSizer working right to left and top to bottom?  (i.e. Unstiffened panel family concepts: one stack = 1, two stack = 2, three stack = 3, honeycomb = 4, foam = 5)

Is there a command I can use to extract the selected material(s) and the controlling failure mode?
for example,
vpdTopFace_ThicknessMaterial gives the sized thickness.

Thanks

Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Visual Basic/COM interface questions
« Reply #1 on: June 18, 2009, 11:07:51 AM »
You can use the Description object with the FamilyConceptText function to extract this information. The FamilyConceptText function needs the Family #(BeamPanelFamily) and the Concept # (pcrConcept or bcrConcept).

Here's an example implementation:

**************************************
Dim objDescription As New Hypersizer.Description

......open a Hypersizer Application and Project...

For Each objGroup In objProject.Groups
      For Each objComp In objGroup.Components
           
          MsgBox ("#" & objComp.Key & "-" & objDescription.FamilyConceptText(objComp.Parent.Family, objComp.ResultPanel(pcrConcept)) )
     
     Next objComp
Next objGroup
*****************************************
Example Output:  "#15-Bonded Trusscore Sandwich"

-Ryan


JEA

  • Client
  • **
  • Posts: 12
    •  
Re: Visual Basic/COM interface questions
« Reply #2 on: August 28, 2009, 11:55:14 AM »
Thanks, I was able to get that to work.

Another question.  How would I go about extracting the selected material and the controlling failure mode?

Using oComp.ResultVariable(vpdTopFace_ThicknessMaterial) gives the top face thickness.

Thanks for any help.

Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Visual Basic/COM interface questions
« Reply #3 on: November 05, 2009, 02:33:00 PM »
Sorry for the delay. 

Getting the controlling failure analysis is fairly straightforward.  Get the analysis id and use the AnalysisText method of the Description object.

*****************************************************

Dim oDes As New HyperSizer.Description

Debug.Print oDes.AnalysisText(oComp.ResultPanel(pcrAnalysisID))


*****************************************************

Getting the material is a little more complicated.  Materials are defined by two pieces of information: 1) Material Type (isotropic, orthotropic etc.) 2) Material key unique for each material in a give type.

Attached is some code from a utility spreadsheet we are developing.  Case selects are used to keep the code general to all material types.

*****************************************************

                Dim lngMatTypeID As Long
                Dim strMatKey As String
   
                Dim oFoam As Foam
                Dim oHC As Honeycomb
                Dim oIso As Isotropic
                Dim oLam As Laminate
                Dim oLay As Layup
                Dim oOrtho As Orthotropic

                lngMatTypeID = oComp.ResultVariableMaterialType(vpdTopFace_ThicknessMaterial) ' Material Type ID
                strMatKey = oComp.ResultVariableMaterialKey(vpdTopFace_ThicknessMaterial, lngMatTypeID) ' Material Key
               
                If Abs(StrComp(strMatKey, "")) > 0 Then ' Make sure that the key is valid
               
                    Select Case lngMatTypeID
                   
                        Case hmtFoam 'Foam'
                            Set oFoam = oHS.Foams.Key(strMatKey)
                            Cells(row, col) = oFoam.MaterialName
                       
                        Case hmtHoneycomb 'Honeycomb'
                            Set oHC = oHS.Honeycombs.Key(strMatKey)
                            Cells(row, col) = oHC.MaterialName
                     
                        Case hmtIsotropic 'Isotropic'
                            Set oIso = oHS.Isotropics.Key(strMatKey)
                            Cells(row, col) = oIso.MaterialName
                       
                        Case hmtLaminate 'Laminate'
                            Set oLam = oHS.Laminates.Key(strMatKey)
                            Cells(row, col) = oLam.MaterialName
               
                        Case hmtLayup 'Lay-Up'
                            Set oLay = oHS.Layups.Key(strMatKey)
                            Cells(row, col) = oLay.MaterialName
   
                        Case hmtOrthotropic 'Orthotropic'
                            Set oOrtho = oHS.Orthotropics.Key(strMatKey)
                            Cells(row, col) = oOrtho.MaterialName
                           
                        Case hmtThermal 'Thermal'
                       
                        Case Else
                            Cells(row, col) = "Invalid Material Type ID"
                   
                    End Select
               
                Else ' Material Key is empty
                     ' - This happens if the select concept doesn't have material data for a give object
                     ' - Example: Unstiffened Plate/Sandwich Panel Family
                     ' -----  Concept: One Stack Unstiffened has no core (key = 0)
                     ' -----  Concept: Honeycomb Sandwich has core (key != 0)
                     Cells(row, col) = ".."
                End If
               
            End If

***************************************************

The Object Model manual has undergone a major revision. It has a more detailed discussion on retrieving material properties and analysis objects. It is available at:
http://www.hypersizer.com/manuals/User_Manual_Programmer.pdf