CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > ANSYS Meshing & Geometry

[DesignModeler] How to Pass values from python journal file to .js file?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 30, 2015, 08:50
Post How to Pass values from python journal file to .js file?
  #1
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
Hello,

I have a journal file run.py file and I am starting a jscript file dm.js from this journal file with sendcommand function

I need to pass values I have calculated in journal file to this js file.
Is there way that these values can be sent through sendcommand function as an argument?
I have tried python file creating a text file and js file reading it. But the file handling functions seem a but tough.

Any help is appreciated.
Thanks
kar.coep is offline   Reply With Quote

Old   April 30, 2015, 18:53
Default
  #2
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Kar,

Could you post your code how you are working it out, whr u r calculating values and why you want it to go to JS file.


KAPI
Kapi is offline   Reply With Quote

Old   May 2, 2015, 06:24
Post
  #3
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
Hello Kapi,

I am taking values from excel file in journal file. Some of these values include meshing sizes. You might be well aware of it, but my journal file code typically looks like this:

Code:
meshmin = worksheet.cell["A20"].value
and I am invoking mesh script file from this journal file

Code:
Mesh1.sendcommand (script.read())
I need to pass this meshmin value to script file, where I am changing mesh minimum size value. One way is to store these values in a text file while journal file code is running and then read it in mesh script. But I am not aware of file reading commands in Javascript. Is there way that I can pass these variables from sendcommand function itself as an argument, like

Code:
mesh1.sendcommand (script.read(),meshmin)
Thanks,
Kartiki
kar.coep is offline   Reply With Quote

Old   May 3, 2015, 22:27
Default
  #4
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Kar,

You can call Excel values in JS directly rather than calling values in Journal file then giving values to JS file.
This I reckon will be much neater way to use excel with JS.

Code:
var excel = new ActiveXObject("Excel.Application");
var excel_file = excel.Workbooks.Open("Excel file path");
var excel_sheet = excel.Worksheets("Sheet1);
meshmin = excel_sheet.Cells(20,1).value;
Hope it helps.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   May 4, 2015, 09:11
Post
  #5
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
Thanks Kapi!!!

That worked.

There was a question on adding mesh method.

I am trying to add Multizone method and the code I am using looks like

Code:
 
sm.AddToSelection(1,0,false);
var MeshCtrlObj = meshGroup.AddMeshControl(sm,DS.Script.id_BodyMeshType);
MeshCtrlObj.Value = 7; // defines multizone method
MeshCtrlObj.SourceTargetSelection = 1; // says to have geometry selection
MeshCtrlObj.SourceGeometry = sm; // gives input geometry
DS.Script.fillTree();
Problem here is I need to select geometry in sm. I am already defining the bodies to be selected as Named selection in Designmodeler. How do I specify this named selection instead of geometry selection here?

Thanks,
Kartiki
kar.coep is offline   Reply With Quote

Old   May 4, 2015, 18:52
Default
  #6
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Kar,

Quote:
sm.AddToSelection(1,0,false);
you need to get TopoID and PartID of the gometry you want to select and then add in sm rather than using (1,0,false)

Code:
sm.AddToSelection(partID[i], aTopoId, false);
Once you find out these values, feed them here or give as a value and then run your new code and it should work for ya!

Hope it helps

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   May 5, 2015, 00:22
Post
  #7
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
Yes.. I am aware of it. I am actually trying to specify named selection instead of Geometry Selection, cause choosing the parts of geometry would be kind of difficult in my case.
kar.coep is offline   Reply With Quote

Old   May 5, 2015, 00:55
Default
  #8
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Kar,

I dont think you can specify Named selection in Source Geometry manually or by Script or even store Named selection in place of Part ID and Topo ID in SM!
Give it a go and let me know if it pans out for u!

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   May 5, 2015, 02:49
Post
  #9
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
yup.. will do.. Thanks!!!

I have some more questions:
1. Is there any property of bodies and faces in design modeler that will specify it's distance from coordinate system?

2. Also if I have id for a body, can I identify bodies that interface with it?

3. Is there any property of a face that says its flat and not curved?

Thanks,
Kartiki
kar.coep is offline   Reply With Quote

Old   May 5, 2015, 18:57
Default
  #10
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Kar,

Quote:
1. Is there any property of bodies and faces in design modeler that will specify it's distance from coordinate system?
I dont think there is any tool which can help you find distance from Coordinate system
There is a tool called "distance finder" it can help you find distance between two entitites but not Coordinate system

Quote:
2. Also if I have id for a body, can I identify bodies that interface with it?
I dont think you can identify that as well. TopoID and PartID are assigned by DesignMDoeler inorder of there creation.

Quote:
3. Is there any property of a face that says its flat and not curved?
You can go to Tools>Analysis Tools>Entity Information.
Once you select this tool, it will give all information about the point/edge/face/body selected

Hope it helps

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   May 6, 2015, 05:28
Post
  #11
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
Thanks Kapi,

How to program distance finder? I need to find distance between a body and a point. I have searched for it in installation folder and on net but couldnot get anything relative.

In meshing, GrowthRateSF is the command to use to edit value of growth rate in inflation in global mesh parameters, I think.
But the following code does not work. It gives error as 'Object doesn't support this property or method'

Code:
 
var meshGroup = DS.Tree.FirstActiveBranch.MeshControlGroup;
DS.Script.changeActiveObject(meshGroup.ID);
meshGroup.GrowthRateSF = 1.2556;

Last edited by kar.coep; May 6, 2015 at 08:36.
kar.coep is offline   Reply With Quote

Old   May 7, 2015, 01:24
Default
  #12
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Kar,

Tried to look for Distance finder but cudnt get anything solid!
Found the below codes but not sure if/how they will work!

Code:
1:
var enable = ag.gui.ProcessButtons("ID_AT_DistanceFinder", mode);
agMode_enable(button, enable);

2:
ag.gui.CreateDimensionDistance()

3:
agToolsHandler("ID_AT_DistanceFinder", 1603)

Regarding Growth rate
Quote:
meshGroup.GrowthRateSF = 1.2556;
this is not the code!, you assumes it would be similar to min size and max size but apparently its no.
Not able to locate it yet but should be something similar.

Will update you if I find something on these!

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   May 7, 2015, 02:28
Post
  #13
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
Hi Kapi,


In ACT reference guide Distance function is mentioned under iQueries as:


Distance(IEnumerable<IPSGeoEntity>, IEnumerable<IPSGeoEntity>)


are you aware of this? I am not sure how to use it in .js file.

Also in ageventhandler in installation folder, there is this code:

ag.gui.CreateAnalysisTools(eventID);
switch(eventID)
{
case 0: // Distance finder
activeProp = "ID_EntitySet1";
break;
case 2: // Bounding box
case 3: // Mass properties
case 4: // Fault detect
case 5: // Small Entity Search
activeProp = "ID_EntitySet";
break;
case 6: // Body clash search
activeProp = "ID_AnalysisToolsBodies";
break;
}
agListviewAnalysisTools();
listviewActivateProp(activeProp);
agGUI_OnCursorWaitOFF();
}

CreateAnalysisTools() command doesnot give any error. But not sure how to give arguments of 2 bodies to it
kar.coep is offline   Reply With Quote

Old   May 7, 2015, 09:31
Post
  #14
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
I have solved the question posted above and would be posting the code soon.

Code:
 
var bodyno = ag.agApplet.FeatureMgr.BodyCount;
var faceno;
var totalfaces = new Array();
var facelbs =new Array();
var m=0;
var fcc, facelb;
for (var i=1;i<bodyno;i++)
{
var inlet = ag.fm.Body(i);
var bodylb = inlet.Label;
ag.m.FindEntity(0, 0, bodylb, 0);
ag.m.SelectionMgr.ShowTopologicalConnections(0);
faceno = ag.m.GetFaceSelListSize();
for (var j=0;j<faceno;j++)
{
fcc = ag.m.GetFaceSelListIndex(j);
facelb = fcc.Label;
totalfaces[m] = find_distance(facelb,ptlb);
facelbs[m] = facelb;
m = m+1;
}
I am getting 80004005 error at
fcc = ag.m.GetFaceSelListIndex(j);

what can cause it? or would be there be any other way that can go through each face of a body?
kar.coep is offline   Reply With Quote

Old   May 7, 2015, 22:43
Default
  #15
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi kar,

Quote:
CreateAnalysisTools() command doesnot give any error. But not sure how to give arguments of 2 bodies to it
dosent give error dosent mean it is right or wrong! it could not be doing anything!
Did you try to see what happens when you call this function? What features are being stored in it?
Once you find what u r getting in the output window of VS, you can just scroll thru the steps to find distance finder and use the same in code.
Good you have the solution now, It will be beneficial for everyone if you can post those codes here!

Quote:
ag.m.GetFaceSelListIndex(j)
I have never used this function before so I have no clue!

Cheers
KAPI
Kapi is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
wmake compiling new solver mksca OpenFOAM Programming & Development 14 June 22, 2018 06:29
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 12:41
[swak4Foam] swak4Foam-groovyBC build problem zxj160 OpenFOAM Community Contributions 18 July 30, 2013 13:14
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 11:46
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 15:16


All times are GMT -4. The time now is 10:08.