Add Circular cross section in mechanical via scripting

Options
cedev
cedev Member Posts: 3
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 Answer

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 208
    First Answer First Comment 5 Likes First Anniversary
    edited May 20 Answer ✓
    Options

    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.

Answers