2011/11/3 Pierre JUILLARD <pierre.juill...@gmail.com>

> Hi Thomas,
>

Hi Pierre,


>
> Thank you for your answers.
>
> Following your advices, I had a look to the 52 posts on the OCC forum that
> are returned when searching with the keyword "unit", but none are
> interesting. They are either irrelevant, or without answer.
>
> I had however a look to the *.cdl file in Units and UnitsAPI folder.
> UnitsAPI.cdl is quite interesting and describes a large number of method
> to achieve conversion.
>
> However, I cannot use it in PythonOCC and don't know why.
>
> I am quite sure it is because I am unfamiliar with Python at the moment.
>
> For instance, typing:
>
> from OCC.UnitsAPI import *
>
> if __name__ == '__main__':
>      u = UnitsAPI()
>      u.CurrentUnit("LENGTH")
>
> returns:
>
> Traceback (most recent call last):
>   File "L:\[coding]\python\pythonOCC_units\unitManagementTest.py", line
> 13, in <module>
>     u.CurrentUnit("LENGTH")
> RuntimeError: Standard_NoSuchObject
>

Same here:
>>> u = UnitsAPI()
>>> u.CurrentUnit("LENGTH")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/OCC/UnitsAPI.py", line 214, in
CurrentUnit
    return _UnitsAPI.UnitsAPI_CurrentUnit(*args)
RuntimeError: Resource_NoSuchResource
LENGTH


>
> I have understood that 2 "configuration" files are needed so that UnitsAPI
> and Units work:
>
> Lexi_Expr.dat
> => a file into which are defined math symbols and unit prefixes so that
> the math parser can work. It looks pretty interesting, but I am not sure it
> is really useful, except maybe for parametric values. I don't know how
> pyOCC PAF works, but if you need  to set for the parameter A a value of
> "B+C", this tool should be able to understand the mathematical meaning of
> this.
> It is also able to understand for instance the k in "10 km" as an
> indication to multiply the value by a factor 10e3, and this for the
> miscellaneous prefixes for each defined units.
> Units_Sentence.cdl, Units_UnitSentence.cdl and Units_MathSentence.cdl are
> the files indicating the methods to use it.
>
> Units.dat
> => a file defining the unit. Fortunately, the concept of unit signature is
> already implemented actually: a very interesting surprise!
>
> Thomas, I understandd that to work in a normal OCC environment, the
> variable "CASROOT" needs to be defined so that OCC is able to retrieve
> these files through the following variables:
> set CSF_UnitsLexicon=%CASROOT%\src\UnitsAPI\Lexi_Expr.dat
> set CSF_UnitsDefinition=%CASROOT%\src\UnitsAPI\Units.dat
>
> How does it work with PythonOCC?
>

These env var don't come with pythonOCC but with OCC. I have these files on
my machine, with env var properly set up, but it fails however.


>  I have installed PythonOCC all in one, but I couldn't find those file
> where I installed PythonOCC: where are the OCC sources installed?
>

Only Windows dll are installed with pyocc, not resource files.


> And do you think that I should define manually these environment variables
> so that PythonOCC is able to find them?
>

These env vars are defined when installing OCC630.


>
> I thank you in advance for your help.
>
> Have a good day.
> Bests,
>
> Pierre
>
> PS: if we succeed using this API, would you be interested that I write a
> python sample to include in PythonOC?
>

Absolutely!

Regards,

Thomas
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to