News: Contact us to upgrade your software!

Author Topic: Adding material to project  (Read 32539 times)

oseresta

  • Client
  • **
  • Posts: 13
    •  
Adding material to project
« on: March 10, 2011, 04:56:25 PM »
1. If I add any new material or a laminate. How can I make the new material or laminate definition available to my existing projects ?
2. I am creating a project thru excel VBA, I want to make certain material available to this project. How can I do that ?

Thanks

Omprakash

oseresta

  • Client
  • **
  • Posts: 13
    •  
Re: Adding material to project
« Reply #1 on: March 15, 2011, 10:44:16 AM »
Can any one from Hypersizer please respond to the above question.

Phil

  • Administrator
  • *****
  • Posts: 218
    • HyperSizer Structural Sizing Software
    •  
Re: Adding material to project
« Reply #2 on: March 15, 2011, 10:57:54 AM »
Omprakash,

I apologize for the delay, our Object Model expert is out of town at a training class and has not had a chance to answer this question yet. I will pass along to him that you are awaiting an answer.

Phil

Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Adding material to project
« Reply #3 on: March 15, 2011, 10:36:34 PM »
In the COM API there is actually no notion of assigning projects to groups. You directly assign materials to groups using the VariableMaterial property of the Group class.

In VBA, create a dynamic string array. Put the laminate keys (strings) in the array, assign the array to VariableMaterial, and save.

    ' Print laminate keys
    Dim oLam As HyperSizer.Laminate
    Dim oLamCol As HyperSizer.LaminateCol
   
    Set oLamCol = oHs.Laminates
    For Each oLam In oLamCol
        Debug.Print oLam.key, oLam.MaterialName
    Next oLam
   
    ' Create string array of laminate keys
    Dim strVarMaterial() As String
    ReDim strVarMaterial(1 To 2)
    strVarMaterial(1) = "20016"
    strVarMaterial(2) = "20055"
   
    ' Assign string array to VariableMaterial
    oGroup.VariableMaterial(vpdTopFace_ThicknessMaterial, hmtLaminate) = strVarMaterial
    oGroup.Save


oseresta

  • Client
  • **
  • Posts: 13
    •  
Re: Adding material to project
« Reply #4 on: March 16, 2011, 07:23:54 AM »
Hi

I am getting this error

Run-time error '-2147188733 (80048003)'

Unhandled Error, Application Error in Group::VariableMaterial[PropertyLet]()

Line#12, Error # 13, Type Mismatch


    Dim strVarMaterial() As String
    ReDim strVarMaterial(1)
   
    strVarMaterial(0) = HS.Laminates.Item(3).Key
    MsgBox (strVarMaterial(0))
    Dim oProjCol As ProjectCol, oGroupCol As GroupCol
    Set oProjCol = HS.Projects
    Set oProj = oProjCol.Item("project01")
    Set oGroupCol = oProj.Groups
    Set oGroup = oGroupCol.Item(2)
    MsgBox (oGroupCol.Item(2).GroupName)
    oGroup.VariableMaterial(vpdTopFace_ThicknessMaterial, hmtLaminate) = strVarMaterial [In this line the debugger shows error]
    oGroup.Save

Thanks for your help

Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Adding material to project
« Reply #5 on: March 16, 2011, 08:50:03 AM »
The array you defined as two entries: strVarMaterial(0) & strVarMaterial(1).

The strVarMaterial(1) entry is not defined which causes the application error.

The VariableMaterial property will ignore the zero index array term. So to add a single material, do this instead:

ReDim strVarMaterial(1 To 1)
strVarMaterial(1) = HS.Laminates.Item(3).Key


Also, note that the array above is dimensioned using an upper and lower bound. It is best practice in VBA to define the arrays this way rather than relying on whatever default is (Option Base).

oseresta

  • Client
  • **
  • Posts: 13
    •  
Re: Adding material to project
« Reply #6 on: March 17, 2011, 04:11:01 PM »
Thanks Ryan. It helped a lot.

One last question.

1. Is it possible to add a orthotropic material thru Object Model.

I didnt see any public method that says create for oHS.Orthotropics.#####
As per my understanding, it seems that only way to create a material is by directly using the material manager GUI. Once the materials are created, it is possible to assign or make it available to groups according to wish via COM

Please correct me if I am wrong.

Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Adding material to project
« Reply #7 on: March 18, 2011, 08:35:44 AM »
It is possible to add a new material. To create a new material: 1) Get a reference to an existing material, 2) change the name, and 3) Execute SaveAsNew().

I will add that materials (other than laminates & layups) should be created very carefully according to your design specifications. This only has to be done once.

Materials can be imported from one database to another using File | Import. Click Advanced to import the materials.

The best way to ensure that materials are used consistently throughout an organization is to create a template database. When a new database is created, the template database (and its materials) are copied to the new database. If all team members are using the correct template database (specified in Preferences | Options) you can be sure that the correct materials and allowables are being used.

Related help topics: http://www.hypersizer.com/help/
Software Forms > Database Explorer > Project and Workspace Import Options
Software Forms > Database Explorer > Template Database
Software Forms > Utilities > HyperSizer Options
« Last Edit: August 22, 2011, 11:39:19 AM by Ryan »

oseresta

  • Client
  • **
  • Posts: 13
    •  
Re: Adding material to project
« Reply #8 on: March 29, 2011, 08:09:06 AM »
Thanks.

Another question

After adding a material to group, is it possible to switch the Radio button from "continuous" to "laminate" as per need from COM.

Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Adding material to project
« Reply #9 on: March 29, 2011, 08:12:18 AM »
It's located in Group.VariableBound

oGroup.VariableBound(vpdTopFace_ThicknessMaterial, vbdLaminateOnly) = True

oseresta

  • Client
  • **
  • Posts: 13
    •  
Re: Adding material to project
« Reply #10 on: March 29, 2011, 08:37:20 AM »
How to set "continuous" option ?

Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Adding material to project
« Reply #11 on: March 29, 2011, 08:38:32 AM »
Set it to 'False'.

oGroup.VariableBound(vpdTopFace_ThicknessMaterial, vbdLaminateOnly) = False