Skip to content

Is there a way to change an exports HEADER section? #1154

Open
@Jeremy-Walton

Description

@Jeremy-Walton

I am exporting a STEP file using this library, but am trying to figure out how to set the header info like File Description, Author, File name, etc.

My current file has

HEADER;
FILE_DESCRIPTION(('Open CASCADE Model'),'2;1');
FILE_NAME('Open CASCADE Shape Model','2022-11-10T20:20:26',('Author'),(
    'Open CASCADE'),'Open CASCADE STEP processor 7.6','Open CASCADE 7.6'
  ,'Unknown');
FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'));
ENDSEC;

I can use STEPControl_Writer().Model().ClearHeader() to remove everything in that section, but I cannot figure out how to change it.

In https://dev.opencascade.org/doc/occt-7.6.0/refman/html/class_step_data___step_model.html#aad41ab9f8467bf843649fdd63040c021 there is a AddHeaderEntity method on the Model which can be called with STEPControl_Writer().Model().AddHeaderEntity() but I cannot figure out how to construct the entity it expects or use it.

I also see https://dev.opencascade.org/doc/occt-7.6.0/refman/html/class_a_p_i_header_section___make_header.html which seems to do exactly what I want, but is not exposed in the python library.

Here is a simplified version of what I'm doing:

from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox

from OCC.Core.STEPControl import STEPControl_Writer, STEPControl_AsIs
from OCC.Core.Interface import Interface_Static_SetCVal
from OCC.Core.IFSelect import IFSelect_RetDone

# creates a basic shape
box_s = BRepPrimAPI_MakeBox(10, 20, 30).Shape()

# initialize the STEP exporter
step_writer = STEPControl_Writer()
dd = step_writer.WS().TransferWriter().FinderProcess()
print(dd)

Interface_Static_SetCVal("write.step.schema", "AP203")

# transfer shapes and write file
Interface_Static_SetCVal('write.step.product.name', 'Box')
step_writer.Transfer(box_s, STEPControl_AsIs)

# step_writer.Model().ClearHeader()
# step_writer.Model().AddHeaderEntity(whatdoiputhere?)

status = step_writer.Write("box.stp")

if status != IFSelect_RetDone:
    raise AssertionError("load failed")

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions