Can't read PMI in STEP exported by ug

The logs in console:

*** ERR StepReaderData : Unresolved Reference : Fails Count : 1 ***
 **  Model Complete Check List  **
Check: 1 -- Global Check
Parameter n0.7 (authorisation) not a quoted String
Check: 2 -- Entity (n0:id) 1:#10   Type:DIMENSIONAL_LOCATION
Parameter n0.4 (shape_aspect_relationship.related_shape_aspect) not an Entity
Check: 5 -- Entity (n0:id) 15:#24   Type:GEOMETRIC_ITEM_SPECIFIC_USAGE
Parameter n0.4 (item_identified_representation_usage.used_representation) not an Entity
Check: 6 -- Entity (n0:id) 16:#25   Type:GEOMETRIC_ITEM_SPECIFIC_USAGE
Parameter n0.4 (item_identified_representation_usage.used_representation) not an Entity
Check: 7 -- Entity (n0:id) 145:#154   Type:REPRESENTATION_MAP
Parameter n0.2 (mapped_representation) not an Entity
Check: 8 -- Entity (n0:id) 146:#155   Type:REPRESENTATION_MAP
Parameter n0.2 (mapped_representation) not an Entity
Check: 9 -- Entity (n0:id) 147:#156   Type:REPRESENTATION_MAP
Parameter n0.2 (mapped_representation) not an Entity
Check:10 -- Entity (n0:id) 148:#157   Type:REPRESENTATION_MAP
Parameter n0.2 (mapped_representation) not an Entity
Check:11 -- Entity (n0:id) 149:#158   Type:REPRESENTATION_MAP
Parameter n0.2 (mapped_representation) not an Entity
Check:12 -- Entity (n0:id) 150:#159   Type:REPRESENTATION_MAP
Parameter n0.2 (mapped_representation) not an Entity
Check:13 -- Entity (n0:id) 151:#160   Type:REPRESENTATION_MAP
Parameter n0.2 (mapped_representation) not an Entity
Check:14 -- Entity (n0:id) 152:#161   Type:REPRESENTATION_MAP
Parameter n0.2 (mapped_representation) not an Entity
Check:15 -- Entity (n0:id) 388:#397   Type:PRESENTATION_STYLE_ASSIGNMENT
Parameter n0.1 (styles) : Entity has illegal type
Check:16 -- Entity (n0:id) 390:#399   Type:PRESENTATION_STYLE_ASSIGNMENT
Parameter n0.1 (styles) : Entity has illegal type
Attachments: 
Lee Dongming's picture

//STEPCAFControl_Reader Reader; // Old Code
STEPCAFControl_Reader Reader(XSDRAW::Session()); //New Code,but call error

Attachments: 
Lewis Alexander's picture

The messages are all about unrecognized entities. This seems like to be a problem about STEP version. You should check the part about the STEP version setting and sort of things.

Reading from and writing to STEP

As for the code, I check the head file of this class STEPCAFControl_Reader There are two construct functions.

STEPCAFControl_Reader ();
STEPCAFControl_Reader (const Handle< XSControl_WorkSession > &WS, const Standard_Boolean scratch=Standard_True);

the first parameter of the 2nd construct function has to be a pre-defined object. So, this will work.

    XSDRAW m;
    STEPCAFControl_Reader Reader(m.Session());

粗略看了一下。你这个文件好像是STEP版本问题吧,读入的时候OCC报出的信息都是显示文件中的某一个STEP entity,在STEP->OCC这个映射里面没有。就是说OCC不能对这个实体做映射,parse成OCC内部的数据。 在OCCT的overview,读写STEP文件那里有这个相关内容。 Reading from and writing to STEP

看了一下这行代码 STEPCAFControl_Reader Reader(XSDRAW::Session()); //New Code,but call error 似乎这个类的只有两种构造函数。 STEPCAFControl_Reader (); STEPCAFControl_Reader (const Handle< XSControl_WorkSession > &WS, const Standard_Boolean scratch=Standard_True); 第二个构造函数的说明要求第一个参数是已经存在的。这样写是ok的。

    XSDRAW m;
    STEPCAFControl_Reader Reader(m.Session());
Lewis Alexander's picture

I sent a bilingual answer just now, was informed that it has to be moderated. So, typing a new one.

1.Messages are all about unrecognized entity. Seems like to be a problem about STEP version. You may check this page for mroe infos. Reading from and writing to STEP

2.The construct function with parameters of this class STEPCAFControl_Reader requires the first parameter to be an already existing obejct.

So, this will work.

    XSDRAW m;
    STEPCAFControl_Reader Reader(m.Session());

and are you a Chinese studen?

Lee Dongming's picture

hhhhh,首先十分感谢回复。不容易啊,终于等到回复了,感觉找到组织了。 我19年毕业的,从学校就一直搞CAD/CAE二次开发。之前搞的3DE/CATIA。现在在一家目标工业4.0公司工作,OCC是技术路线之一。 有联系方式不,[手动狗头],mail:moodlee@qq.com 一个一个回复哈。

First

The step file is exported by UG NX 2007, and the protocol is AP242. My code is:

bool Test()
{
    STEPCAFControl_Reader Reader;
    Reader.SetColorMode(true);
    Reader.SetGDTMode(true);
    Reader.SetLayerMode(true);
    Reader.SetMatMode(true);
    Reader.SetNameMode(true);
    Reader.SetPropsMode(true);
    Reader.SetSHUOMode(true);
    try
    {
        OCC_CATCH_SIGNALS;
        if (Reader.ReadFile(TmpPath) != IFSelect_RetDone)
        {
            return false;
        }
        //...Some Codes To Check
        if (!Reader.Transfer(Target))
        {
            return false;
        }
    }
    catch (Standard_Failure const& theFailure)
    {
        cout<<theFailure.GetMessageString()<<endl;
        return false;
    }
    return true;
}

Step Version? Do you mean : Interface_Static::SetIVal("write.step.schema", 5);? So Read step version is Interface_Static::SetIVal("read.step.schema", 5);?

Second

Demo Code:

#include <iostream>
#include <XSDRAW.hxx>
#include <STEPCAFControl_Reader.hxx>

int main()
{
    XSDRAW m;
    STEPCAFControl_Reader Reader(m.Session());
}

Press F5 to Debug:

0x00007FFA7FDB127E (TKXSBase.dll)处(位于 Demo.exe 中)引发的异常: 0xC0000005: 读取位置 0x0000000000000030 时发生访问冲突
Lee Dongming's picture

The Define:

  //! Returns the WorkSession defined in AddDraw (through Pilot)
  //! It is from XSControl, it brings functionalities for Transfers
  Standard_EXPORT static Handle(XSControl_WorkSession) Session();

So

XSDRAW m;
STEPCAFControl_Reader Reader(m.Session());

Same with

STEPCAFControl_Reader Reader(XSDRAW::Session());
Lewis Alexander's picture

LOL I’m new to the OCCT, too. What I replied formerly is wrong, and sorry for that! Actually I don't really know how to use the class STEPCAFControl_Reader, I just thought that might work. So I replied and don't run it on my pc. My apology!

I try to read your file with STEPControl_Reader, and get the same messages as you.

However, I don't know how to initialize the STEPCAFControl_Reader.

I tried codes below to initialize this class

    Handle(XSControl_WorkSession) t = new XSControl_WorkSession;
    STEPCAFControl_Reader reader(t);
    IFSelect_ReturnStatus stat = reader.ReadFile(filename);

    Standard_Boolean failsonly = Standard_False;
    IFSelect_PrintCount mode = IFSelect_ItemsByEntity;
    reader.Reader().PrintCheckLoad(failsonly, mode);

the variable stat turns out to be IFSelect_RetVoid

the PrintCheckLoad() shows the message below

 **    **
Check:1 -- Global Check
DATA NOT AVAILABLE FOR CHECK

However, if I use the STEPControl_Reader 's data member to initialize the class, it will get the same as use the STEPControl_Reader to read the file directly.

    STEPControl_Reader t;
    STEPCAFControl_Reader reader(t.WS());
    IFSelect_ReturnStatus stat = reader.ReadFile(filename);
Lee Dongming's picture

I sent a bilingual answer just now too....
waiting....
Do you have any contact methods? My mail is moodlee@qq.com

Kirill Gavrilov's picture

STEP translation log specifies that dimension is attached to "not an Entity". So either, STEP document is broken (doesn't conform to standard) or OCCT doesn't handle some allowed combination.

19:34 Fails on Reading Header Entity N0.5:HeaderSection_FileName
19:34 Parameter n0.7 (authorisation) not a quoted String
19:34 *** ERR StepReaderData : Unresolved Reference : Fails Count : 1 ***
19:34 ...    Step File Reading : 'C:/spring.stp'      ...    STEP File   Read    ...
            ... Step File loaded  ...
         1375 records (entities,sub-lists,scopes), 4061 parameters      ... Parameters prepared ...
            ...   Objects analysed  ...
        STEP Loading done : 800 Entities
19:34 Count	STEP Reader Failures for 'spring.stp'
       -----	-----------
           1	F: Parameter n0.7 (authorisation) not a quoted String
           1	F:DIMENSIONAL_LOCATION: Parameter n0.4 (shape_aspect_relationship.related_shape_aspect) not an Entity
           1	W:(LENGTH_MEASURE_WITH_UNIT,MEASURE_REPRESENTATION_ITEM,MEASURE_WITH_UNIT,QUALIFIED_REPRESENTATION_ITEM,REPRESENTATION_ITEM): Complex Record n0.16, member type MEASURE_WITH_UNIT not in alphabetic order
           1	W:(LENGTH_MEASURE_WITH_UNIT,MEASURE_REPRESENTATION_ITEM,MEASURE_WITH_UNIT,QUALIFIED_REPRESENTATION_ITEM,REPRESENTATION_ITEM): Complex Record n0.23, member type MEASURE_WITH_UNIT not in alphabetic order
           2	F:GEOMETRIC_ITEM_SPECIFIC_USAGE: Parameter n0.4 (item_identified_representation_usage.used_representation) not an Entity
           8	F:REPRESENTATION_MAP: Parameter n0.2 (mapped_representation) not an Entity
           2	F:PRESENTATION_STYLE_ASSIGNMENT: Parameter n0.1 (styles) : Entity has illegal type
          Nb Total:16  for 7 items
19:34 Count	STEP Translator Warnings for 'spring.stp'
       -----	-----------
           3	W:ADVANCED_FACE: Missing seam-edge added
          Nb Total:3  for 1 items

Lee Dongming's picture

hi~~~Thanks for your reply.
I understand what you mean, but the step file is exported by UG.
Will they not comply with AP242 specifications?
It's bad news.

However, are there some methods to solve the problem?
If there is a solution, thank you very much.

Kirill Gavrilov's picture

I don't know if STEP file is valid or not - for this, you need to read STEP standard and check the places, where OCCT parser shows complains / doesn't read. The price of another software cannot tell straight ahead if it writes standard-conforming or non-conforming files. If you cannot solve the problem on your own, you may use support services / register bugs on Bugtracker, so that experts will be able to take a look.

Lee Dongming's picture

Thanks for your advice.
I will take into account.