Convert from CAD file input to desired output units

Similar issue regarding this topic:

Although the previous link seems to be solved for the author, I'm unable to make it work:
I have a STEP file (see attached file) where the main units are millimeters, I want to convert that to other values e.g. meters.

I'm setting the static variable before creating the reader:

    STEPCAFControl_Controller::Init();
    auto hasVariable = Interface_Static::SetIVal("xstep.cascade.unit", 'M'); 
    auto reader = STEPCAFControl_Reader();
    reader.SetColorMode(true);
    reader.SetNameMode(true);
    reader.SetLayerMode(true);
    reader.SetPropsMode(true);

    auto returnStatus = reader.ReadFile(UtilsCli::ToStdString(fullFileName).c_str());
    if (returnStatus != IFSelect_RetDone)
    {
        throw CreateReadFileException(fullFileName, returnStatus);
    }

    TCollection_ExtendedString extendedStringCollection;
    Handle(TDocStd_Document) documentHandle = new TDocStd_Document(extendedStringCollection);
    if (!reader.Transfer(documentHandle))
    {
        throw CreateTransferDocumentException(fullFileName);
    }

I would expect to receive some transformation or vertices different from the normal reading but this is not the case.
Apart from that, do you have any documentation regarding on which kind of parameters xstep.cascade.unit allow?

I'm using 7.7.2 version

Kind regards,
Lorenzo Navarro

Attachments: 
Lorenzo Napl's picture

Still having issues with this:

I created a STEP file with FreeCad, I exported it with Units for export of STEP set to meters.
I asume that the export process works, because when opening the file I'm able to see the units:
#346 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT($,.METRE.) );

After that when I try to use XCAFDoc_DocumentTool::GetLengthUnit() I only get 0.001, where I suppose that I should get 1.
After reading this topic (where they seem to have the same issue as me), it seems that XCAFDoc_DocumentTool::GetLengthUnit() it is only used to define or get units into which file will be converted during import process...

Any functional way to get the units from a CAD file?

Kind regards,
Lorenzo Navarro

Attachments: 
Dmitrii Pasukhin's picture

XCAFDoc_DocumentTool::GetLengthUnit() describe system unit of the document.

As for a STEP file each root be able to have own unit. I don't know the way to fully determine the whole file unit.

Best regards, Dmitrii.

Lorenzo Napl's picture

Is it possible then to get the root unit?

Kind regards,
Lorenzo Navarro

Dmitrii Pasukhin's picture

"xstep.cascade.unit" - system unit to convet INTO.

This parameter is ignored when document has own unit attribute(the same functionality, just document has highest priority).

Best regards, Dmitrii.