Add Circular cross section in mechanical via scripting

cedev
cedev Member Posts: 5
First Comment
**

Hi,

I am trying to add a circular cross section in mechanical via the scripting interface.

I can add one using either commands if there is already the "Cross Sections" folder:
cs = Model.CrossSections.AddCircularCrossSection()
cs = ExtAPI.DataModel.Project.Model.CrossSections.AddCircularCrossSection()

If I try to run it when the CrossSections folder doesn't exist I have the following error message:
'NoneType' object has no attribute 'AddCircularCrossSection'

What am I missing?

Best Answers

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 297
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited May 20 Answer ✓

    Looks like the API is missing coverage for this. I will work with our developers to get it fixed. As a workaround, you can use InternalObject, but please note it is undocumented and unsupported:

    ExtAPI.DataModel.Project.Model.InternalObject.AddCrossSectionGroup()
    Tree.Refresh()
    

    @mohamed-koubaa, FYI. Will reach out to discuss.

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 85
    Second Anniversary 10 Comments 5 Answers Solution Developer Community of Practice Member
    ✭✭✭✭
    Answer ✓

    This will be exposed in 2025R1.

Answers