How to link the TexGen Python library in Anaconda?
Moderators: Martin, Developers
How to link the TexGen Python library in Anaconda?
Hi, everyone:
I installed TexGen by .exe. And I wanted to run the .py file through Spyder(Anaconda3). But I don't how to link the TexGen Python library.
Does this way work? Should I change to intall TexGen by compiling from source?
Thank you for helping.
Regards,
why
I installed TexGen by .exe. And I wanted to run the .py file through Spyder(Anaconda3). But I don't how to link the TexGen Python library.
Does this way work? Should I change to intall TexGen by compiling from source?
Thank you for helping.
Regards,
why
Re: How to link the TexGen Python library in Anaconda?
Hi Why,
I haven't tried this myself but I would think that you need to make sure that the TexGen Python libraries are accessible to your anaconda installation. You may need to either add them to your path or copy them to where you're running your Spyder project from. You should find the libraries in the TexGen->Python->libxtra folder (probably in Program Files if that's where you installed TexGen to).
I would think that you also need to make sure that the anaconda Python version is compatible with TexGen which is built with Python2.7.
I can't see that building TexGen from source would make any difference as this will just build that same libraries.
Hope that helps,
Louise
I haven't tried this myself but I would think that you need to make sure that the TexGen Python libraries are accessible to your anaconda installation. You may need to either add them to your path or copy them to where you're running your Spyder project from. You should find the libraries in the TexGen->Python->libxtra folder (probably in Program Files if that's where you installed TexGen to).
I would think that you also need to make sure that the anaconda Python version is compatible with TexGen which is built with Python2.7.
I can't see that building TexGen from source would make any difference as this will just build that same libraries.
Hope that helps,
Louise
Re: How to link the TexGen Python library in Anaconda?
Dear Louise,louisepb wrote:Hi Why,
I haven't tried this myself but I would think that you need to make sure that the TexGen Python libraries are accessible to your anaconda installation. You may need to either add them to your path or copy them to where you're running your Spyder project from. You should find the libraries in the TexGen->Python->libxtra folder (probably in Program Files if that's where you installed TexGen to).
I would think that you also need to make sure that the anaconda Python version is compatible with TexGen which is built with Python2.7.
I can't see that building TexGen from source would make any difference as this will just build that same libraries.
Hope that helps,
Louise
Your help is much appreciated. I am truly thankful for your help.
Besides path problems, I also encountered a problem with .pyd. I copied all .dll files in TexGen folder to the library(libxtra\TexGen), and there was no more error messages.
But I'm not sure if it works, so I run a script working fine in GUI, but it fails in my terminal. It seems that the master nodes are not created.
Code: Select all
C:\Users\epzlpb\Documents\Code\TexGen\Core\YarnSectionInterpNode.cpp(98) : Unable to get section, the number of sections specified (5) is not equal to the number of nodes (1)Code: Select all
from _Embedded import *
from TexGen.Core import *
from TexGen.Renderer import *
from TexGen.Export import *
from TexGen.WeavePattern import *
from TexGen.WiseTex import *
from TexGen.FlowTex import *
import math
from math import *
Textile = CTextile()
a1=0.895
b1=0.35
a2=0.57
b2=0.23
spacing1=3.932
spacing2=1.315
spacing3=1.23
spacing4=0.01
shearAngle=pi/8
twistAngle = shearAngle
shearOffset = 0
shearOffset2 = spacing2*sin(shearAngle)
Yarns = [CYarn()]
Yarns[0].AddNode(CNode(XYZ(0, 0, 1.5*spacing2)))
Yarns[0].AddNode(CNode(XYZ(1*spacing1, 0+shearOffset, 0.5*spacing2)))
Yarns[0].AddNode(CNode(XYZ(2*spacing1, 0+2*shearOffset, -0.5*spacing2)))
Yarns[0].AddNode(CNode(XYZ(3*spacing1, 0+3*shearOffset, 0.5*spacing2)))
Yarns[0].AddNode(CNode(XYZ(4*spacing1, 0+4*shearOffset, 1.5*spacing2)))
yarnsection = CYarnSectionInterpNode()
#---------------------------------------------------------
ellipse = CSectionPowerEllipse(2*a1, 1.5*b1, 0.6, 0)
yarnsection.AddSection(ellipse)
ellipse = CSectionPowerEllipse(2.5*a1, 2.5*b1, 0.6, 0)
yarnsection.AddSection(ellipse)
ellipse = CSectionPowerEllipse(3*a1, 1.5*b1, 0.6, 0)
yarnsection.AddSection(ellipse)
ellipse = CSectionPowerEllipse(2.7*a1, 2.7*b1, 0.6, 0)
yarnsection.AddSection(ellipse)
ellipse = CSectionPowerEllipse(2*a1, 1.5*b1, 0.6, 0)
yarnsection.AddSection(ellipse)
#---------------------------------------------------------
Yarns[0].AssignSection(yarnsection)
Textile.AddYarn(Yarns[0])
AddTextile("1-3 twill RVE_withAngle", Textile)
te = GetTextile()
yarn = te.GetYarn(0)
sections = yarn.GetYarnSection()
pos = YARN_POSITION_INFORMATION()
pos.SectionLengths = DoubleVector( yarn.GetSectionLengths() )
# pos.iSection = 1
pos.dSectionPosition = 0
Points = sections.GetSection(pos, 100)
area = CSection.GetArea(Points)
print areaRe: How to link the TexGen Python library in Anaconda?
Hi Why,
There is a yarn.GetNumNodes() function described here:
http://texgen.sourceforge.net/api/class ... _yarn.html
I think that the issue is that a single instance of the CTexGen class is created and AddTextile adds to that instance. Try using TEXGEN.GetTextile as TEXGEN is a macro which gets the texgen instance.
Hope that helps,
Louise
There is a yarn.GetNumNodes() function described here:
http://texgen.sourceforge.net/api/class ... _yarn.html
I think that the issue is that a single instance of the CTexGen class is created and AddTextile adds to that instance. Try using TEXGEN.GetTextile as TEXGEN is a macro which gets the texgen instance.
Hope that helps,
Louise
Re: How to link the TexGen Python library in Anaconda?
Dear Louise,louisepb wrote:Hi Why,
There is a yarn.GetNumNodes() function described here:
http://texgen.sourceforge.net/api/class ... _yarn.html
I think that the issue is that a single instance of the CTexGen class is created and AddTextile adds to that instance. Try using TEXGEN.GetTextile as TEXGEN is a macro which gets the texgen instance.
Hope that helps,
Louise
Thank you for your reply. I've tried a lot of times but failed. I think I haven't get the instance successfully as you said. And I got confused about the member GetYarn.
In the documentation, I found GetYarn is a member of CTextile class. In my script Textile = CTextile(), so I tried to use the code below, but it didn't work.
Code: Select all
Textile.GetYarn[0]http://texgen.sourceforge.net/phpBB3/vi ... area#p6990
Code: Select all
gt = GetTextile()
yarn = gt.GetYarn(0)I tried to use TXEGEN.GetTextile, but I found I know nothing about the macro and it seems that it's quite different from Python Module.
Could you please tell me how to use it or is there any other way to get the instance ?
Regards
why
Re: How to link the TexGen Python library in Anaconda?
Hi Why,
Apologies for the confusion. TEXGEN is a macro when getting the instance in a C++ program. You should be able to just use the AddTextile and it should work. If you do want to get the instance you can use CTexGen.GetInstance().
I think that the problem that you're seeing here is the brackets. In the first sample you use square brackets but GetYarn is a python function and therefore expecting normal parentheses to take the yarn number as a function parameter.
Hope that helps,
Louise
Apologies for the confusion. TEXGEN is a macro when getting the instance in a C++ program. You should be able to just use the AddTextile and it should work. If you do want to get the instance you can use CTexGen.GetInstance().
I think that the problem that you're seeing here is the brackets. In the first sample you use square brackets but GetYarn is a python function and therefore expecting normal parentheses to take the yarn number as a function parameter.
Hope that helps,
Louise
Re: How to link the TexGen Python library in Anaconda?
Dear Loiuse,louisepb wrote:Hi Why,
Apologies for the confusion. TEXGEN is a macro when getting the instance in a C++ program. You should be able to just use the AddTextile and it should work. If you do want to get the instance you can use CTexGen.GetInstance().
I think that the problem that you're seeing here is the brackets. In the first sample you use square brackets but GetYarn is a python function and therefore expecting normal parentheses to take the yarn number as a function parameter.
Hope that helps,
Louise
Sorry for bothering you so many times. I didn't explain clearly.
I made a mistake that I typed wrong, I used normal parenthesis in the script.
I found something strange. When I print GetSectionLengths() in GUI, it returns vectors. But when I print it in my IDE, I got ().
Code: Select all
gt = GetTextile()
yarn = gt.GetYarn(0)
ls = yarn.GetSectionLengths()
print lsRegards
why
Re: How to link the TexGen Python library in Anaconda?
Dear Why,
Could you send the complete script so I can try and work out what's going on? Can you check that your GetTextile has actually retrieved the correct textile by calling textile.GetName(). If you have created more than one textile then GetTextile() without a name parameter will return the one most recently added.
Best wishes,
Louise
Could you send the complete script so I can try and work out what's going on? Can you check that your GetTextile has actually retrieved the correct textile by calling textile.GetName(). If you have created more than one textile then GetTextile() without a name parameter will return the one most recently added.
Best wishes,
Louise
Re: How to link the TexGen Python library in Anaconda?
Dear Louise,louisepb wrote:Dear Why,
Could you send the complete script so I can try and work out what's going on? Can you check that your GetTextile has actually retrieved the correct textile by calling textile.GetName(). If you have created more than one textile then GetTextile() without a name parameter will return the one most recently added.
Best wishes,
Louise
Sorry for replying so late. The script is in the attachment with some screenshots of the results. The code is the same as the one in upper poster.
Many thanks for your help.
Why
- Attachments
-
- code wtih screenshots.zip
- (151.77 KiB) Downloaded 116 times
Re: How to link the TexGen Python library in Anaconda?
Hi Why,
It's not easy to see what's going on here. I don't have a Python IDE on the borrowed computer I'm using to work from home at the moment.
I don't really understand why you do the GetTextile command after you've done the AddTextile? Why don't you just carry on using the Textile parameter you had originally? It might be worth trying that. Otherwise, try using the textile name as a parameter in the GetTextile and see if that resolves the issue.
Sorry not to be more help.
Best wishes,
Louise
It's not easy to see what's going on here. I don't have a Python IDE on the borrowed computer I'm using to work from home at the moment.
I don't really understand why you do the GetTextile command after you've done the AddTextile? Why don't you just carry on using the Textile parameter you had originally? It might be worth trying that. Otherwise, try using the textile name as a parameter in the GetTextile and see if that resolves the issue.
Sorry not to be more help.
Best wishes,
Louise
Re: How to link the TexGen Python library in Anaconda?
Dear Louise,louisepb wrote:Hi Why,
It's not easy to see what's going on here. I don't have a Python IDE on the borrowed computer I'm using to work from home at the moment.
I don't really understand why you do the GetTextile command after you've done the AddTextile? Why don't you just carry on using the Textile parameter you had originally? It might be worth trying that. Otherwise, try using the textile name as a parameter in the GetTextile and see if that resolves the issue.
Sorry not to be more help.
Best wishes,
Louise
Thank you very much for your help.
It seems original Textile parameter doesn't have the attribute e.g. GetArea. It sounds very strange but I tried in TexGen GUI and () returned.
However, once using GetTextile, I can GetSectionLengths, GetYarnSection and so on.
All in all, Thank you very much for your kind help.
Best wishes,
why