VBA sheet metal face not working- wrong side of sketch

VBA sheet metal face not working- wrong side of sketch

revans1234
Enthusiast Enthusiast
781 Views
3 Replies
Message 1 of 4

VBA sheet metal face not working- wrong side of sketch

revans1234
Enthusiast
Enthusiast

Hello, this problem is making no sense so I wonder if anyone else has met it.

 

In the attachment there are 3 tabs.

 

The code to make the closed loop tab shape is the same in each case.

 

The tab on the orange side has been made into a face using the VBA face feature "add" used as in the demo code. Here is an extract in my code.

 

    Dim oFaceFeatureDefinition As FaceFeatureDefinition
    Set oFaceFeatureDefinition = oSheetMetalFeatures.FaceFeatures.CreateFaceFeatureDefinition(Prof)
   
    ' Create a face feature.
    Dim oFaceFeature As FaceFeature
    Set oFaceFeature = oSheetMetalFeatures.FaceFeatures.ADD(oFaceFeatureDefinition)

 

Prof is the closed loop tab shape.

 

The tab on the flange edge vertical in the picture has been done the same way, but the face is clearly not correct.

 

The lowest tab has been made into a face manually using the ribbon face command. It is correct.

 

I am trying to find out why.

 

I have tried-

-drawing the profile the other way round.

-AddForSurface instead of AddForSolid- does not work- this is only for surfaces

-Drawing my sketch on the other face of the flange (the inside face)- still got an incorrect face, but now on the other face.

 

Has anyone any ideas? If you use the VBA face feature successfully on flanges, how do you do it?

 

Thanks and regards,

 

Roger.

 

 

 

 

 

 

 

0 Likes
Accepted solutions (1)
782 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Accepted solution

I am just trying to figure all this out so take this accordingly. It appears that the vertical tab is extruded in the wrong direction. Perhaps putting a negative value in there would help. Or changing the initial face selection to the interior face of the channel would be more appropriate. If you can post the code also that would be a big help.

 

Kevin

 

0 Likes
Message 3 of 4

revans1234
Enthusiast
Enthusiast

Hello Kevin,

 

Yes, it does seem to extrude the wrong way, but there does not seem to be control on the direction. We are using the sheetmetal Face command, which normally (and in this case when done manually) extrudes in the direction of existing material.

 

I tried drawing on the inside of the channel, and got the same (wrong) result.

 

The code is large, but the key parts are that before it has drawn the rectangles on the sketch, it does this.

 

Dim ObCollProf As ObjectCollection
Set ObCollProf = ThisApplication.TransientObjects.CreateObjectCollection

 

At the end of the drawing it does this

 

Debug.Print "obcoll profile segment count = " & CStr(ObCollProf.COUNT)
Debug.Print "profile count before add = " & CStr(SK.Profiles.COUNT)
Set Prof = SK.Profiles.AddForSolid(False, ObCollProf)

 

It return through the subroutines, then closes the sketch editing then adds the face feature

 

    Call SK.ExitEdit
    '###############################################################
     ' Set a reference to the component definition.
    Dim oCompDef As SheetMetalComponentDefinition
    Set oCompDef = SMCD 'sheetmetal component definition derived before.
    
    ' Set a reference to the sheet metal features collection.
    Dim oSheetMetalFeatures As SheetMetalFeatures
    Set oSheetMetalFeatures = oCompDef.Features


    Dim oFaceFeatureDefinition As FaceFeatureDefinition
    Set oFaceFeatureDefinition = oSheetMetalFeatures.FaceFeatures.CreateFaceFeatureDefinition(Prof)
   
    ' Create a face feature.
    Dim oFaceFeature As FaceFeature
    Set oFaceFeature = oSheetMetalFeatures.FaceFeatures.ADD(oFaceFeatureDefinition)

 

This last line causes the face.

 

Remember it all works fine for the first sketch (which defines the channel outline). It seems it is always on the wrong side for everything else.

 

I can't see where the direction is changed- for the Face command manually you never set direction or thickness.

 

So thinking about what you said-

 

If I extrude (i.e. not Face) the profile manually to the correct thickness, it does generate the flat pattern correctly. So if I VBA the extrude with the additional control of direction the VBA Extrude function should give, it might work. I think I will try that.

 

Thanks,

 

Roger.

 

 

 

 

0 Likes
Message 4 of 4

revans1234
Enthusiast
Enthusiast

So further to this, I tried the following lines to use extrusion-

Prof is the profile loop

PCD is the partcomponentdefinition

 

    Dim ExDef As ExtrudeDefinition
    Set ExDef = PCD.Features.ExtrudeFeatures.CreateExtrudeDefinition(Prof, kJoinOperation)
    Call ExDef.SetDistanceExtent(0.12, kNegativeExtentDirection) 'hardcoded thickness
    Call PCD.Features.ExtrudeFeatures.ADD(ExDef)

 

With this it is possible to force the extent direction.

 

And it now all works fine- the flat pattern is OK too.

 

So Kevin gets the solution- thanks very much for that.

 

Roger.

 

 

 

 

0 Likes