[Ironpython-users] IronPython, Daily Digest 2/20/2015
CodePlex
no_reply at codeplex.com
Sat Feb 21 16:34:29 CET 2015
Hi ironpython,
Here's your Daily Digest of new issues for project "IronPython".
In today's digest:ISSUES
1. [New comment] Lower casing non-ASCII characters does not work
2. [New issue] Problem with API in IronPython
----------------------------------------------
ISSUES
1. [New comment] Lower casing non-ASCII characters does not work
http://ironpython.codeplex.com/workitem/33133
User paweljasinski has commented on the issue:
"<p>I believe it is fixed in 2.7.4</p><p>$ git tag --contains c02becc<br>ipy-2.7.4<br>ipy-2.7.4-a1<br>ipy-2.7.4-b1<br>ipy-2.7.4-b2<br>ipy-2.7.4-rc1<br>ipy-2.7.5<br>ipy-2.7.5-b1<br>ipy-2.7.5-b2<br>ipy-2.7.5-b3<br>ipy-2.7.5-rc1<br>ipy-2.7.5-rc2</p><p><br>--pawel</p>"-----------------
2. [New issue] Problem with API in IronPython
http://ironpython.codeplex.com/workitem/35858
User Dado87 has proposed the issue:
"Hi everyone,
I have an issue with running of some code in IronPyrhon (actually in GHPython script Editor, which uses IronPython). I want to run some structural engineering software (Strand7) externaly with the help of API of this software. If I run it in Python IDLE it works well, but inside Iron I get some error. Please look at the attached .pdf file. Code is writen below.
Do somebody know what's wrong? Any sugestions? Thanks for the answears!
Regards,
Damir
from St7API import *
import ctypes
import os
import sys
# Error checking function. Turns a non-zero integer returned by Strand API call into a Python exception
def ChkErr(ErrorCode):
ErrorOccured = (ErrorCode != 0)
if ErrorOccured:
ErrorString = ctypes.create_string_buffer(kMaxStrLen)
# Attempt to get API error string
iErr = St7GetAPIErrorString(ErrorCode, ErrorString, kMaxStrLen)
# If that failed, attempt to retrive a solver error string
if iErr:
iErr = St7GetSolverErrorString(ErrorCode, ErrorString, kMaxStrLen)
if not iErr:
raise Exception('%s (%d)' % (ErrorString.value, ErrorCode))
else:
raise Exception('An unknown error occured (%d)' % ErrorCode)
return ErrorOccured
# Program
def CreatePoint(pCoord)
ChkErr(St7Init())
def RunPlateDemo(modPath, nIters = 1, showWindow = True, maxThickness = 2):
# Wrap everything in a try/except/finally block so the API is unloaded even after an exception
try:
# Initialise
ChkErr(St7Init())
# Open the file
ChkErr(St7OpenFile(1, modPath, r'c:\Users\D.Kovacevic\AppData\Local\Temp'.encode()))
# Show the model window if that was requested
if showWindow:
ChkErr(St7CreateModelWindow(1))
ChkErr(St7ShowModelWindow(1))
ChkErr(St7PositionModelWindow(1, 0, 0, 640, 480))
# Set results file name to model name without extension
resFileName = os.path.splitext(modPath)[0]
ChkErr(St7SetResultFileName(1, resFileName))
# Perform optimsation several times if requested
for iIter in range(nIters):
# Run Linear Static Solver
ChkErr(St7RunSolver(1, stLinearStaticSolver, smBackgroundRun, 1))
# Open results files
nPrim, nSec = ctypes.c_int(), ctypes.c_int()
ChkErr(St7OpenResultFile(1, resFileName + '.lsa'.encode(), ''.encode(), False, nPrim, nSec))
# Get the number of plates and iterate over them, saving the VM stress
nPlatesCtypes = ctypes.c_int()
numPoints, numCols = ctypes.c_int(), ctypes.c_int()
ChkErr(St7GetTotal(1, tyPLATE, nPlatesCtypes))
# Build dictionary of PlateNum->VM Stress
plateVM = {}
plateResultArrayType = ctypes.c_double * kMaxPlateResult
plateResArray = plateResultArrayType()
print (plateResArray)
for iPlate in range(1, nPlatesCtypes.value + 1):
ChkErr(St7GetPlateResultArray(1, rtPlateStress, stPlateCombined, iPlate, 1, AtCentroid,
psPlateMidPlane, 0, numPoints, numCols, plateResArray))
plateVM[iPlate] = plateResArray[ipPlateCombVonMises]
# Close results file
ChkErr(St7CloseResultFile(1))
# Get the units
unitsArrayType = ctypes.c_long * kLastUnit
units = unitsArrayType()
ChkErr(St7GetUnits(1, units))
vmVals = plateVM.values()
meanVM = sum(vmVals)/len(vmVals)
print('[%d/%d] Min/Mean/Max VM Stress: %f/%f/%f %s'%(iIter+1, nIters, min(vmVals), meanVM, max(vmVals), unitStrings.get(units[ipSTRESSU], '??Units')))
# Modify plate thicknesses
plateAttributeType = ctypes.c_double * kMaxAttributeDoubles
plateAttribs = plateAttributeType()
for iPlate in range(1, nPlatesCtypes.value + 1):
ChkErr(St7GetPlateThickness2(1, iPlate, plateAttribs))
newThickness = min([plateAttribs[ipTHICKM] * plateVM[iPlate]/meanVM, maxThickness])
plateAttribs[ipTHICKM] = newThickness
plateAttribs[ipTHICKB] = newThickness
ChkErr(St7SetPlateThickness2(1, iPlate, plateAttribs))
if showWindow:
ChkErr(St7UpdateElementPropertyData(1, ptPLATEPROP, 1))
ChkErr(St7RedrawModel(1, True))
# Save and close
ChkErr(St7SaveFile(1))
finally:
# These calls are made even if an exception was raised in the main block
if showWindow:
ChkErr(St7DestroyModelWindow(1))
St7CloseFile(1)
St7Release()
path = "OptimisationModel.st7"
pathx = str(path)
pathy = pathx.encode()
RunPlateDemo(modPath = pathy, nIters = 2)
"
----------------------------------------------
----------------------------------------------
You are receiving this email because you subscribed to notifications on CodePlex.
To report a bug, request a feature, or add a comment, visit IronPython Issue Tracker. You can unsubscribe or change your issue notification settings on CodePlex.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20150221/36270f83/attachment.html>
More information about the Ironpython-users
mailing list