Personal tools
You are here: Home Forum Other... (new forum, problems, etc.) Problem to get a the geometry part from the HDF file.

Problem to get a the geometry part from the HDF file.

Up to Other... (new forum, problems, etc.)

Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

Hi,

I open a file in HDF format, I find the GEOM object "MyGeom", but I cannot modify it or generate a mesh from it.

What did I do wrong ? This script gives an error on the last line.

Thanks.

 

import salome
import geompy

salome.salome_init()

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

p0 = geompy.MakeVertex(0, 0, 0)
factor = 1000
Shape = geompy.MakeScaleTransform(sobject, p0, factor)

Re: Problem to get a the geometry part from the HDF file.

Posted by Saint Michael at December 14. 2010

Hi Olivier

You additionally need to retrieve GEOM_Object from SObject:

geomObject = sobject.GetObject()._narrow( GEOM.GEOM_Object)

...

Shape = geompy.MakeScaleTransform(geomObject, p0, factor)

BR SM

Re: Problem to get a the geometry part from the HDF file.

Posted by Saint Michael at December 14. 2010

To be exact

geomObject = sobject.GetObject()._narrow( geompy.GEOM.GEOM_Object)

Re: Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

Thank you for your help. I still have an error message:

geomObject = sobject.GetObject()._narrow(geompy.GEOM.GEOM_Object)
AttributeError: 'NoneType' object has no attribute '_narrow'

Bye,

OR

Re: Problem to get a the geometry part from the HDF file.

Posted by Saint Michael at December 14. 2010

Try to call "import geompy" after opening your study

 

Re: Problem to get a the geometry part from the HDF file.

Posted by Erwan ADAM at December 14. 2010

Previously Olivier Roussel wrote:

Hi,

I open a file in HDF format, I find the GEOM object "MyGeom", but I cannot modify it or generate a mesh from it.

What did I do wrong ? This script gives an error on the last line.

Thanks.

 

import salome
import geompy

salome.salome_init()

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

p0 = geompy.MakeVertex(0, 0, 0)
factor = 1000
Shape = geompy.MakeScaleTransform(sobject, p0, factor)

Try to replace :

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

by

study   = salome.myStudyManager.Open("MyFile.hdf")

geom = salome.lcc.FindOrLoadComponent("FactortServer", "GEOM")
from GEOM import GEOM_Gen
geom = geom._narrow(GEOM_Gen)
mySComp = study.FindComponent('GEOM')
myBuilder = study.NewBuilder()
myBuilder.LoadWith(mySComp, geom)

sobject = salome.myStudy.FindObject("MyGeom")

Re: Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

I did it, and nothing changed.

 

Re: Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

Previously Erwan ADAM wrote:

Previously Olivier Roussel wrote:

Hi,

I open a file in HDF format, I find the GEOM object "MyGeom", but I cannot modify it or generate a mesh from it.

What did I do wrong ? This script gives an error on the last line.

Thanks.

 

import salome
import geompy

salome.salome_init()

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

p0 = geompy.MakeVertex(0, 0, 0)
factor = 1000
Shape = geompy.MakeScaleTransform(sobject, p0, factor)

Try to replace :

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

by

study   = salome.myStudyManager.Open("MyFile.hdf")

geom = salome.lcc.FindOrLoadComponent("FactortServer", "GEOM")
from GEOM import GEOM_Gen
geom = geom._narrow(GEOM_Gen)
mySComp = study.FindComponent('GEOM')
myBuilder = study.NewBuilder()
myBuilder.LoadWith(mySComp, geom)

sobject = salome.myStudy.FindObject("MyGeom")

Thanks for your answer, but it doesn't work. I have an error message:

Shape = geompy.MakeScaleTransform(sobject, p0, factor)
  File "/opt/SALOME-MECA-2010.1-x86_64/SALOME/SALOME5/V5_1_3/GEOM_V5_1_3/bin/salome/geompyDC.py", line 2571, in MakeScaleTransform

which means that the object "sobject" is not of good type.

OR

 

Re: Problem to get a the geometry part from the HDF file.

Posted by Erwan ADAM at December 14. 2010

Previously Olivier Roussel wrote:

Previously Erwan ADAM wrote:

Previously Olivier Roussel wrote:

Hi,

I open a file in HDF format, I find the GEOM object "MyGeom", but I cannot modify it or generate a mesh from it.

What did I do wrong ? This script gives an error on the last line.

Thanks.

 

import salome
import geompy

salome.salome_init()

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

p0 = geompy.MakeVertex(0, 0, 0)
factor = 1000
Shape = geompy.MakeScaleTransform(sobject, p0, factor)

Try to replace :

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

by

study   = salome.myStudyManager.Open("MyFile.hdf")

geom = salome.lcc.FindOrLoadComponent("FactortServer", "GEOM")
from GEOM import GEOM_Gen
geom = geom._narrow(GEOM_Gen)
mySComp = study.FindComponent('GEOM')
myBuilder = study.NewBuilder()
myBuilder.LoadWith(mySComp, geom)

sobject = salome.myStudy.FindObject("MyGeom")

Thanks for your answer, but it doesn't work. I have an error message:

Shape = geompy.MakeScaleTransform(sobject, p0, factor)
  File "/opt/SALOME-MECA-2010.1-x86_64/SALOME/SALOME5/V5_1_3/GEOM_V5_1_3/bin/salome/geompyDC.py", line 2571, in MakeScaleTransform

which means that the object "sobject" is not of good type.

OR

 

Could you upload hdf file ?

Re: Problem to get a the geometry part from the HDF file.

Posted by Saint Michael at December 14. 2010

You have forgotten about

Shape = geompy.MakeScaleTransform(geomObject, p0, factor)

BR SM

Re: Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

Previously Erwan ADAM wrote:

Previously Olivier Roussel wrote:

Previously Erwan ADAM wrote:

Previously Olivier Roussel wrote:

Hi,

I open a file in HDF format, I find the GEOM object "MyGeom", but I cannot modify it or generate a mesh from it.

What did I do wrong ? This script gives an error on the last line.

Thanks.

 

import salome
import geompy

salome.salome_init()

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

p0 = geompy.MakeVertex(0, 0, 0)
factor = 1000
Shape = geompy.MakeScaleTransform(sobject, p0, factor)

Try to replace :

study   = salome.myStudyManager.Open("MyFile.hdf")
sobject = salome.myStudy.FindObject("MyGeom")

by

study   = salome.myStudyManager.Open("MyFile.hdf")

geom = salome.lcc.FindOrLoadComponent("FactortServer", "GEOM")
from GEOM import GEOM_Gen
geom = geom._narrow(GEOM_Gen)
mySComp = study.FindComponent('GEOM')
myBuilder = study.NewBuilder()
myBuilder.LoadWith(mySComp, geom)

sobject = salome.myStudy.FindObject("MyGeom")

Thanks for your answer, but it doesn't work. I have an error message:

Shape = geompy.MakeScaleTransform(sobject, p0, factor)
  File "/opt/SALOME-MECA-2010.1-x86_64/SALOME/SALOME5/V5_1_3/GEOM_V5_1_3/bin/salome/geompyDC.py", line 2571, in MakeScaleTransform

which means that the object "sobject" is not of good type.

OR

 

Could you upload hdf file ?

The uploading of the HDF file works well. The FindObject too. The problem concern the type of data that can be read by a geompy function such as MakeScaleTransform.

Re: Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

Previously Saint Michael wrote:

You have forgotten about

Shape = geompy.MakeScaleTransform(geomObject, p0, factor)

BR SM

I don't think so. Here is my script:

 

import salome
import geompy

salome.salome_init()

study = salome.myStudyManager.Open("ANCA.hdf")
sobject = study.FindObject("ANCA_Geom")

geomObject = sobject.GetObject()._narrow( geompy.GEOM.GEOM_Object)

p0 = geompy.MakeVertex(0, 0, 0)
factor = 1000

Shape = geompy.MakeScaleTransform(geomObject, p0, factor)

 

And here is the error message:

geomObject = sobject.GetObject()._narrow( geompy.GEOM.GEOM_Object)
AttributeError: 'NoneType' object has no attribute '_narrow'

 

The error seems to be in the definition of geomObject.

Re: Problem to get a the geometry part from the HDF file.

Posted by Saint Michael at December 14. 2010

I don't think so. Here is my script:

You should combine the both advices.

BR SM

Re: Problem to get a the geometry part from the HDF file.

Posted by Erwan ADAM at December 14. 2010

Previously Saint Michael wrote:

I don't think so. Here is my script:

You should combine the both advices.

BR SM

Exactly ...
The object "sobject" is a Study Object so you cannot call a geom function on it.
geomObject = sobject.GetObject() will return None unless you have loaded the data via the geom component which is done by the LoadWith instructions.

Re: Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

According to both of your ideas, the script is:

import salome
import geompy

salome.salome_init()

study = salome.myStudyManager.Open("ANCA.hdf")

geom = salome.lcc.FindOrLoadComponent("FactortServer", "GEOM")
from GEOM import GEOM_Gen
geom = geom._narrow(GEOM_Gen)
mySComp = study.FindComponent('GEOM')
myBuilder = study.NewBuilder()
myBuilder.LoadWith(mySComp, geom)

sobject = study.FindObject("ANCA_Geom")
geomObject = sobject.GetObject()._narrow(geompy.GEOM.GEOM_Object)

p0 = geompy.MakeVertex(0, 0, 0)
factor = 1000
Shape = geompy.MakeScaleTransform(geomObject, p0, factor)

 

And I still have the same error on MakeScaleTransform at the end:

 

Shape = geompy.MakeScaleTransform(geomObject, p0, factor)
File "/opt/SALOME-MECA-2010.1-x86_64/SALOME/SALOME5/V5_1_3/GEOM_V5_1_3/bin/salome/geompyDC.py", line 2571, in MakeScaleTransform

 

Re: Problem to get a the geometry part from the HDF file.

Posted by Saint Michael at December 14. 2010

Olivier

Could you provide the output of "print geomObject" and a full trace of the error you get.

BR SM

Re: Problem to get a the geometry part from the HDF file.

Posted by DAVID Gilles at December 14. 2010

Hello,

Replace

geom = salome.lcc.FindOrLoadComponent("FactortServer", "GEOM")

by

geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")

Regards,

Gilles

Re: Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

The instruction

print geomObject

returns:

 

<GEOM._objref_GEOM_Object instance at 0x7f3b28a92908>

 

OR

Re: Problem to get a the geometry part from the HDF file.

Posted by Olivier Roussel at December 14. 2010

The problem is solved now. The last mistake was in "FactortServer". Thank you very much for your help and your time.

Re: Problem to get a the geometry part from the HDF file.

Posted by Saint Michael at December 14. 2010
And I still have the same error on MakeScaleTransform at the end:

Shape = geompy.MakeScaleTransform(geomObject, p0, factor)
File "/opt/SALOME-MECA-2010.1-x86_64/SALOME/SALOME5/V5_1_3/GEOM_V5_1_3/bin/salome/geompyDC.py", line 2571, in MakeScaleTransform

The trace is cut by you or by forum engine?

Quick reply
URLs will be automatically hyperlinked. Basic HTML tags are OK.
Powered by Ploneboard
History
Activate by Olivier Roussel on Dec 14, 2010 03:26 PM
Document Actions