cancel
Showing results for 
Search instead for 
Did you mean: 

API - How to Apply Constraint Along a Curve

Experimenter
Experimenter

Having trouble trying to apply a fixed constraint along curve "5" in my model. This is my last piece of code:

 

 

 'Apply constraint
 Dim BCs As femap.BCSet
 Set BCs = App.feBCSet

 Dim Fixed As femap.BCGeom
 Set Fixed = App.feBCGeom

 Dim BCDef As femap.BCDefinition
 Set BCDef = App.feBCDefinition

 Dim BCsetID As Long
 Dim BCID As Long

 BCsetID=BCs.NextEmptyID
 BCs.title = "Boundary Conditions"
 BCs.Put(BCsetID)
 Fixed.setID = BCsetID

    BCID = BCDef.NextEmptyID
    BCDef.setID = BCsetID
 BCDef.OnType = FT_CURVE
 BCDef.dataType = FT_BCO_GEOM
 BCDef.title = "Fixed Edge"
 BCDef.Put(BCID)

 Fixed.type = 0
 Fixed.geomTYPE = 4
 Fixed.geomID = -5
 Fixed.layer = 1
    Fixed.Put(Fixed.NextEmptyID)

    BCs.Get(BCsetID)
    BCs.Expand()
    BCDef.Get(BCID)
    BCDef.OnType = FT_CURVE
 BCDef.dataType = FT_BCO_GEOM
    BCDef.Put(BCID)
    BCs.Compress()

2 REPLIES

Re: API - How to Apply Constraint Along a Curve

Siemens Genius Siemens Genius
Siemens Genius

Your code is close. You're missing a few things:

 

 Fixed.BCDefinitionID = BCID
 Fixed.type = 0
 Fixed.geomTYPE = 4
 Fixed.geomID = 5
 Fixed.layer = 1
 Fixed.vdof = Array( 1, 1, 1, 1, 1, 1 )
 Fixed.Put(Fixed.NextEmptyID)

  • In the yellow highlighted code, you missed specifying the definition id on the geometric constraint. You can do like you did with the definition
  • In the orange highlighted code, the geometry id is specified as a single positive value. Unlike other calls where you can optionally pass in either a set ID containing a range of IDs or a negative value to denote a single ID, this property is only ever a single value; therefore its value is always positive
  • Finally, while you specified the type as 0 (BFG_DOF), you must also specify the degrees of freedom. In the UI we simplfy it by only giving the option for fixed (1-6), pinned (1-3) or no rotation (4-6), but in the API you've still got to specify them. That's shown on the blue highlighted line. I used the shorthand notation to pass a variant array back to the object, however you could optionally set each DoF one-at-a-time via the individual indicies in the property array

 

The code at the end of expanding / compressing the constraint isn't required.

 

A couple of troubleshooting suggestions should you run into any more problems

  • Try editing the constraint you've made in the UI... either editing the constraint or editing where applied. If the dialog doesn't come up, it means that something was incorrectly set in the object, and it's not a graphical glitch somewhere
  • Easiest way to see how an object might need to be set up when it's not intuative is to just create one first in the UI, then query the individual properties in the debugger. Loads and boundary conditions can be some of the trickier things to set up, so I find that to be useful

 

Hope that helps.

 

Re: API - How to Apply Constraint Along a Curve

Experimenter
Experimenter

This works! Wow, this is a great response. You explained this very well. Thank you so much for your help here! I greatly appreciate it!