For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Adding data to a STEP file.

Anonymous's picture
Forums: 

Hello,

I am attempting to attach additional data to entities in a STEP file and am having trouble. From an earlier suggestion I have tried writing code that uses AddWithRefs(), but I always get a, "Nothing to write", error. Here is some code that I used to see if I could attach the text: "SYS_LVL" as a unique entity that refers back to a part:

Handle(Transfer_FinderProcess) findProc = writer.WS()->TransferWriter()->FinderProcess();

IFSelect_ReturnStatus status = writer.Transfer( assembly->getShape(), STEPControlStd_AsIs );

Handle(TransferBRep_ShapeMapper) mapper =

TransferBRep::ShapeMapper( findProc, assembly->getShape() );

Handle(StepVisual_TextLiteral) sysLevelPart = new StepVisual_TextLiteral();

Handle( TCollection_HAsciiString ) sysLvlName =

new TCollection_HAsciiString( "SYS_LVL" );

sysLevelPart->SetName( sysLvlName );

writer.Model()->AddWithRefs( sysLevelPart, 5 );

The value of '5' in AddWithRefs() is not what I eventually want, but I don't know what to put there. Since there is no documentation for this low level function, I am just trying to decide what it does.

Eventually I want to be able to add boolean, integer, floating point and character data to the file as well. Can anyone please tell me how to do this?

Thanks,

-- Shaun Bloom

Betenev Andrey's picture

Hello Shaun,

While I am not quite sure I understand the exact reason of your problem, I would propose couple of hints, perhaps it will help.

> Hello,

> I am attempting to attach additional data to
> entities in a STEP file and am having
> trouble. From an earlier suggestion I have
> tried writing code that uses AddWithRefs(),
> but I always get a, "Nothing to
> write", error. Here is some code that I
> used to see if I could attach the text:
> "SYS_LVL" as a unique entity that
> refers back to a part:

> Handle(Transfer_FinderProcess) findProc =
> writer.WS()->TransferWriter()->FinderProcess();

> IFSelect_ReturnStatus status =
> writer.Transfer( assembly->getShape(),
> STEPControlStd_AsIs );

> Handle(TransferBRep_ShapeMapper) mapper =

> TransferBRep::ShapeMapper( findProc,
> assembly->getShape() );

> Handle(StepVisual_TextLiteral) sysLevelPart
> = new StepVisual_TextLiteral();

> Handle( TCollection_HAsciiString )
> sysLvlName =

> new TCollection_HAsciiString(
> "SYS_LVL" );

> sysLevelPart->SetName( sysLvlName );

Unfortunately, it is not enough to set only a name to this entity. To get it correct, you have to feed it with all the relevant data. Use the second method Init() (with 6 arguments, see CDL or HXX) to do this.

> writer.Model()->AddWithRefs(
> sysLevelPart, 5 );

> The value of '5' in AddWithRefs() is not
> what I eventually want, but I don't know
> what to put there. Since there is no
> documentation for this low level function, I
> am just trying to decide what it does.

The documentation is in CDL, try to find it and have a look. For function AddWithRefs, use only first argument: the second will be 0 by default, this simply means that your entity will be added with all its references recursively.

> Eventually I want to be able to add boolean,
> integer, floating point and character data
> to the file as well. Can anyone please tell
> me how to do this?

It depends on meaning of that data, see STEP standard

Best Regards,

Andrey

> Thanks,

> -- Shaun Bloom

Shaun Bloom's picture

Hello again,

My code now looks like this:

Handle(StepVisual_TextLiteral) sysLevelPart = new StepVisual_TextLiteral();

Handle( TCollection_HAsciiString ) sysLvlTag = new TCollection_HAsciiString( "SYS_LVL" );

Handle( TCollection_HAsciiString ) value = new TCollection_HAsciiString( "value" );

StepGeom_Axis2Placement placement;

Handle( TCollection_HAsciiString ) alignment = new TCollection_HAsciiString( "" );

StepVisual_TextPath textPath;

StepVisual_FontSelect font;

sysLevelPart->Init( sysLvlTag, value, placement, alignment, textPath, font );

writer.Model()->AddWithRefs( sysLevelPart );

This code fails to put an entity in the STEP file. What I really want to do is to attach boolean, text, integer or floating point data to geometry entities that have already been transferred to the writer object. The values themselves have no predefined meaning in the STEP file - they only have meaning to applications that will read the STEP file. For example, one parameter is an integer key value in a database that indicates what surface property should be attached to a given shape. Clearly, this data is not a "STEP" data item, but I want to store it as a STEP entity that complies with AP214 so that another application can read the file and get the data.

My code above simply tries to create a valid STEP AP214 text entity and put it in the file. In addition to this I need to learn how to make that entity refer back to a geometrical shape that is already in the writer object. The StepVisual_TextLiteral entity that I am trying to use may not be the most appropriate object to use since it includes font and placement data which is irrelevant to my intended purpose. I have tried to use StepBasic_ProductDefinitionRelationship to make the text entity refer back to a geometrical shape , but without success.

Thanks again for your help,

-- Shaun Bloom

Betenev Andrey's picture

Hello,

> Hello again,

> My code now looks like this:

Sorry, but this is not enough: to get this entity properly initialised, you should properly initialise all entities that it refers. In your case with StepVisual_TextLiteral entity, it is placement, textPath and font that you have to initialize by setting real data to them, for instance:

StepGeom_Axis2Placement placement;

Handle(StepGeom_Axis2Placement3d) placement3d =new StepGeom_Axis2Placement3d;

Handle( TCollection_HAsciiString ) p3dname = new TCollection_HAsciiString( "" );

placement3d->Init ( p3dname, gp_Pnt(0,0,0),Standard_False,0,Standard_False,0);

... and so on... Sorry, this is a way in which STEP works, you often have to put a lot of surplus information. Perhaps TextLiteral is not exactly what you need.

> Handle(StepVisual_TextLiteral) sysLevelPart
> = new StepVisual_TextLiteral();

> Handle( TCollection_HAsciiString ) sysLvlTag
> = new TCollection_HAsciiString(
> "SYS_LVL" );

> Handle( TCollection_HAsciiString ) value =
> new TCollection_HAsciiString(
> "value" );

> StepGeom_Axis2Placement placement;

> Handle( TCollection_HAsciiString ) alignment
> = new TCollection_HAsciiString( ""
> );

> StepVisual_TextPath textPath;

> StepVisual_FontSelect font;

> sysLevelPart->Init( sysLvlTag, value,
> placement, alignment, textPath, font );

> writer.Model()->AddWithRefs( sysLevelPart
> );

> This code fails to put an entity in the STEP
> file. What I really want to do is to attach
> boolean, text, integer or floating point
> data to geometry entities that have already
> been transferred to the writer object. The
> values themselves have no predefined meaning
> in the STEP file - they only have meaning to
> applications that will read the STEP file.
> For example, one parameter is an integer key
> value in a database that indicates what
> surface property should be attached to a
> given shape. Clearly, this data is not a
> "STEP" data item, but I want to
> store it as a STEP entity that complies with
> AP214 so that another application can read
> the file and get the data.

You have two variants:

a) try to find construction defined in STEP AP214 that allows to store the kind of data you want, and use it. This will allow you to create STEP files that will be understood by other applications. However, this can be not easy, for instance, to simply assign a color to a sinngle geometric entity in STEP according to AP214, you have to create 19 new entities.

b) or put your data in your own, specific way. Right method would be to create your own STEP entities, but it is not easy... Or you may use existing STEP entities, for instance, put your data in some entities inheriting from StepRepr_RepresentationItem and connect them to your target entities with help of StepRepr_MappedItem.

The simplest way would be to encode all your data into text string and put it directly to 'name' field of your target geometric entity of interest.

Best Regards,

Andrey

> My code above simply tries to create a valid
> STEP AP214 text entity and put it in the
> file. In addition to this I need to learn
> how to make that entity refer back to a
> geometrical shape that is already in the
> writer object. The StepVisual_TextLiteral
> entity that I am trying to use may not be
> the most appropriate object to use since it
> includes font and placement data which is
> irrelevant to my intended purpose. I have
> tried to use
> StepBasic_ProductDefinitionRelationship to
> make the text entity refer back to a
> geometrical shape , but without success.

> Thanks again for your help,

> -- Shaun Bloom

Vijayaragavan's picture

Hello
I too have a same problem.How to manipulate the imported step file.ie,how to get the dimensions of entity or modify the dimensions of entity.I am working in 2D to 3D conversion project..If u found out the answer please tell me..It will be more helpful for my project..Give some idea in 2D to 3D conversion..

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.