cancel
Showing results for 
Search instead for 
Did you mean: 

API Face Splitting: Curve from Surface > Project

Valued Contributor
Valued Contributor

Hello all - I am trying to write a custom API to help with some of my surface splitting tasks.  In the GUI, I frequently use the Curve from Surfaces > Project command in order to perform "face splitting."  I am open to other methods though if there are better options for use with API.

 

Looking in the API reference, it appears that the API equivalent to Curve from Surfaces > Project command is to use feCurveProjectOntoSurfaces and also to set the feCurveUpdateSurfaces flag to TRUE.

 

I am trying to acconplish two things: 1) Use API to split a surface using a curve projected normal to the surface and 2) determine the surface identification of the newly formed surface.  

 

I cannot get commands above to successfully split a surface.  I have model with a single surface and a single curve that crosses it.  I have tried code below without success.  And I am not sure at all how to recover the surface ID of the new surfaces when I do get it working.

 

Any help would be appreciated.  Thank you.

 

Sub Main
    Dim App As femap.model
    Set App = feFemap()
    Dim surfSet As Set
    Set surfSet = App.feSet
    Dim sid As Long                        'surf ID
    Dim    curveSet As Set
    Set curveSet = App.feSet
    Dim cid As Long                        'curve ID
    Dim norm As Variant                '
    Dim Base As Variant
    Dim rc As Long


    'select surfs to split
    rc = surfSet.Select(FT_SURFACE, True, " Select surfaces to split")
    'select curves to project
    rc = curveSet.Select(FT_CURVE, True, " Select curves to project normal")
    '    set geom update flag
    rc = App.feCurveUpdateSurfaces(True, True)
    'split geom
    rc = App.feCurveProjectOntoSurfaces( True, norm, surfSet.ID,curveSet.ID, True)
    
End Sub

Which does not throw any errors but does not split my surface either.

3 REPLIES

Re: API Face Splitting: Curve from Surface > Project

Siemens Phenom Siemens Phenom
Siemens Phenom

You did not get the curves to imprint because the variant norm was empty, so I added the values to that variant.


I recommend you use the feTrackData object and methods to track any new entity IDs created in an API and then put them into a set object.


This API script should work for you:

 

The HTML Clipboard

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim rc As Long

    Dim surfSet As femap.Set
    Set surfSet = App.feSet
    Dim sid As Long                        'surf ID
    Dim curveSet As femap.Set
    Set curveSet = App.feSet
    Dim cid As Long                        'curve ID

    Dim normv(3) As Double
    normv(0) = 0.0
    normv(1) = 0.0
    normv(2) = 1.0
    Dim norm As Variant
    norm = normv

    'select surfs to split
    rc = surfSet.Select(FT_SURFACE, True, " Select surfaces to split")
    'select curves to project
    rc = curveSet.Select(FT_CURVE, True, " Select curves to project normal")

    'Entity Tracking for New Geometry
    Dim newGeom As femap.TrackData
    Set newGeom = App.feTrackData
    Dim newSurfs As femap.Set
    Set newSurfs = App.feSet
    Dim newsID As Long
    Dim newCurves As femap.Set
    Set newCurves = App.feSet
    Dim newcID As Long
    newGeom.StartGeometry ( )

    '    set geom update flag
    rc = App.feCurveUpdateSurfaces(True, True)
    'split geom
    rc = App.feCurveProjectOntoSurfaces( True, norm, surfSet.ID,curveSet.ID, True)

    'Add New Geometry to the New Geometry Sets
    newGeom.StopAll
    newGeom.Created ( FT_SURFACE, newSurfs.ID, True )
    newGeom.Created ( FT_CURVE, newCurves.ID, True )

End Sub

Best Regards,
Chip Fricke
Principal Applications Engineer - Femap Product Development

Re: API Face Splitting: Curve from Surface > Project

Valued Contributor
Valued Contributor

Hi Chip - Thanks so much for the reply!  I will admit, I am both embarrassed and confused (story of my life). 

 

In the doucmentation for feCurveProjectOntoSurfaces shown below, it says that the along field (norm in our case) is ignored unless the projectNormal field is set to FALSE.  In my snippet, I have set projectNormal to TRUE and so I have a followup question: Is it actually making use of the value of the vector? Or does it just need to be intialized to some value? If the former, I am having a hard to reconciling that with the documentation.

 

Regarding the feTrackData object/methods: Perfect!  You saved me at least a day of scouring the API reference!  Thanks again!

curvefromsurfdoc.JPG

 

Re: API Face Splitting: Curve from Surface > Project

Siemens Phenom Siemens Phenom
Siemens Phenom

Even if an argument is 'ignored', it should be able to be evaluated, especially if it is a Variable like in this case.

Best Regards,
Chip Fricke
Principal Applications Engineer - Femap Product Development