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

STEP Import - Multibody case, First body is getting wrongly scaled data from STEPControl_Reader

Vishwas Mane's picture
Forums: 

Hello, I am trying to import STEP files with STEPControl_Reader. It worked for mostly all files.For a single multibody STEP file, it's not working perfectly. For the attached file '3D FRONT WTB.STEP', when i import a file first body is getting very large w.r.t other bodies. When we check the body parameters like volume, area, etc,  those are very large quantities for only the first body. Though this file imports totally fine in any CAD. If you think i am missing on something please let me know. I am sharing the code snippet used for STEP import. Please help me with this issue ASAP    

           string name = Path.GetFileNameWithoutExtension(theFileName);
            STEPControl_Reader aReader = new STEPControl_Reader();
            IFSelect_ReturnStatus aStatus = aReader.ReadFile(theFileName);
            int ic = Interface.Interface_Static.IVal("xstep.cascade.unit");
            string unit = Interface.Interface_Static.CVal("xstep.cascade.unit");
            Interface.Interface_Static.SetCVal("xstep.cascade.unit", "M");
            unit = Interface.Interface_Static.CVal("xstep.cascade.unit");
            if (aStatus == IFSelect_ReturnStatus.IFSelect_RetDone)
            {
                bool isFailsonly = false;
                aReader.PrintCheckLoad(isFailsonly, IFSelect_PrintCount.IFSelect_ItemsByEntity);

                int aNbRoot = aReader.NbRootsForTransfer();
                aReader.PrintCheckTransfer(isFailsonly, IFSelect_PrintCount.IFSelect_ItemsByEntity);
                for (int n = 1; n <= aNbRoot; n++)
                {
                    bool ok = aReader.TransferRoot(n);
                    int aNbShap = aReader.NbShapes();
                    if (aNbShap > 0)
                    {
                        for (int i = 1; i <= aNbShap; i++)
                        {
                            TopoDS_Shape aShape = aReader.Shape(i);

                            IKernelBody body = new OCCBody(aShape);

                            ReadOnlyCollection<IKernelBody> subBodies = body.GetBodies();
                            if (subBodies.Count == 0 || isTopLevel)
                            {
                                body.Name = name;
                                (document as OCCDocument).AddBody(body);
                            }
                            else
                            {
                                for (int j = 0; j < subBodies.Count; j++)
                                {
                                    IKernelBody sn3DBody = subBodies[j];
                                    sn3DBody.Name = name + "-Body" + (j + 1).ToString();
                                    (document as OCCDocument).AddBody(sn3DBody);
                                }
                            }

                        }

                    }
                }
            }

Attachments: 
Benjamin Bihler's picture

I cannot open your STEP file with CATIA v5 (the contents of the file are not transferred, so the document looks empty). Could it be that there is something wrong with your file?

Benjamin

Vishwas Mane's picture

Hello Benjamin,
 Thanks for prompt reply.
 File successfully opens in SolidWorks, SolidEdge, Inventor, NX, etc. I have not tried to open it in Catia though. Can you please try with any other CAD and let me know your suggestion for me on this issue?

 The file is generated with HOOPS.

-Vishwas

Benjamin Bihler's picture

I am sorry, I have no other software that I could try. But it looks to me as if there was no issue with Open CASCADE.

Benjamin

Vishwas Mane's picture

Hi Benjamin, you can try opening file in any free viewer too. It opens correctly. I am just asking am i making any mistake while importing the file may be that's why it's scaling first body.  

liuhuiwei's picture

The file import error.use the file contain units

a.png is importer error message

b.png is the imported step rendering image

c.png is not scaled solid

Attachments: 
liuhuiwei's picture

scale the solid that not scale with factor 0.001,then look well

Attachments: 
Vishwas Mane's picture

Thanks a lot, Liuhuiwei, I appreciate your answer. But how can we check only the specific body/bodies requires a scale from multiple bodies?  

Andrey BETENEV's picture

Hello,

The problem is that the STEP file lacks some entities, in particular ones defining units for the first solid (e.g. entity #85 is missing), AND that default OCCT units are changed to meters.
Due to having no information on units for the first solid, OCCT translates it assuming it is in the default units, i.e. meters, while other solids are explicitly defined in millimeters.
You will get all the solids translated with the same scale if you comment out the line:

Interface.Interface_Static.SetCVal("xstep.cascade.unit", "M");

Please consider fixing the source of such files rather than trying to get valid results reading invalid data.

Andrey

Vishwas Mane's picture

Thanks you Andrey. Yes, Fixing file is the proper solution. This solved the issue.

liuhuiwei's picture

Yes,use units of meter is a solution.The file exporter has error.

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.