Skip to content

Commit 1c8a64e

Browse files
authored
Allow shims of AnyBodyCon exe files on PATH (#118)
* allowed any extension for the AnyBodyCon executable Formatted with black * Refactored tools.py so changes to anybodycon doesn't affect linux * Add changelog entry * Update demo examples * Bumped version to 1.13 * Update toml and dependencies * Skipped test on older python versions
1 parent 99c2ee5 commit 1c8a64e

File tree

27 files changed

+1603
-1412
lines changed

27 files changed

+1603
-1412
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
test:
2525
strategy:
2626
matrix:
27-
env: ["test", "test-py37"]
27+
env: ["test"]
2828
runs-on: windows-latest
2929
needs: lint
3030
steps:

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
**Added:**
77
* Added a "LoadData" macro command can generate the macro for loading h5 files.
8+
* Allow the "AnyBodyCon" executable on path to have any valid windows executable extension (exe, bat, cmd etc.).
9+
This will allow users to use custom shim of the AnyBodyCon executables to point else where.
810

911
## v1.12.2
1012

anypytools/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"NORMAL_PRIORITY_CLASS",
3737
]
3838

39-
__version__ = "1.12.2"
39+
__version__ = "1.13.0"
4040

4141

4242
def print_versions():

anypytools/abcutils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def execute_anybodycon(
175175
macro.append("exit")
176176

177177
if not os.path.isfile(anybodycon_path):
178-
raise IOError(f"Can not find anybodycon.exe: {anybodycon_path}")
178+
raise IOError(f"Can not find anybodycon: {anybodycon_path}")
179179

180180
with open(macrofile_path, "w+b") as fh:
181181
fh.write("\n".join(macro).encode("UTF-8"))
@@ -444,8 +444,8 @@ class AnyPyProcess(object):
444444
This defaults to the number of logical CPU cores in the computer.
445445
anybodycon_path : str, optional
446446
Overwrite the default anybodycon.exe file to
447-
use in batch processing. Defaults to what is found in the windows
448-
registry.
447+
use in batch processing. Defaults to 'AnyBodyCon' on path, or
448+
to what is found in the windows registry.
449449
timeout : int, optional
450450
Maximum time (i seconds) a model can run until it is terminated.
451451
Defaults to 3600 sec (1 hour).

anypytools/tools.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -553,23 +553,19 @@ def get_anybodycon_path() -> str | None:
553553
If AnyBodyCon.exe is on path it will take precedence over
554554
the registry lookup.
555555
"""
556-
anybodycon_path = shutil.which("AnyBodyCon.exe")
557-
558-
if anybodycon_path:
559-
return anybodycon_path
560-
561556
if not ON_WINDOWS:
562557
wineprefix = Path(os.environ.get("WINEPREFIX", Path.home() / ".wine"))
563558
abtpath = wineprefix / "drive_c/Program Files/AnyBody Technology"
564559
anybodycon_paths = list(abtpath.glob("*/AnyBodyCon.exe"))
565-
if anybodycon_paths:
566-
return str(anybodycon_paths[-1])
567-
else:
560+
if not anybodycon_paths:
568561
return None
562+
return str(anybodycon_paths[-1])
563+
564+
anybodycon_path = shutil.which("anybodycon") or lookup_anybody_in_registry()
569565

570-
anybodycon_path = lookup_anybody_in_registry()
571566
if "~" in anybodycon_path:
572567
anybodycon_path = _expand_short_path_name(anybodycon_path)
568+
573569
return anybodycon_path
574570

575571

docs/Tutorial/Tutorial_files/BatchProcess/Demo.Arm2D.any

+87-63
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,58 @@
11
/**
2-
File: Demo.Arm2D.any
3-
4-
Copyright (c) 1999-2011, AnyBody Technology A/S
5-
6-
All rights reserved.
7-
8-
9-
102
This is a demonstration of a simple arm model comprising
113
two degrees of freedom and a selected number of muscles.
124
Features in this model are
135

14-
- definition of muscles
15-
- application of muscle recruitment analysis in
16-
the AnyBodyStudy
17-
- redundancy of the muscle configuration
186

7+
* definition of muscles
8+
* application of muscle recruitment analysis in the AnyBodyStudy</li>
9+
* redundancy of the muscle configuration</li>
1910

2011
The file has the following sections:
21-
- The Arm Model
22-
- Reference frames
23-
- Segments
24-
- Joints
25-
- Drivers
26-
- Loads
27-
- Muscles
28-
- "The body study"
12+
13+
* The Arm Model
14+
15+
* Reference frames
16+
* Segments
17+
* Joints
18+
* Drivers
19+
* Loads
20+
* Muscles
21+
22+
* "The body study"
2923

3024
Notice that all these section could be separate files
3125
that are assemble in a single main file by #include
3226
statements. All include statements must be inside the
33-
"Main = {};" statement in this main file.
27+
``Main = {};`` statement in this main file.
3428

3529
*/
3630
Main = {
31+
32+
33+
// Control if the external load is applied
34+
#ifndef CONFIG
35+
#define CONFIG "Loaded"
36+
#endif
37+
38+
AnyFolder InputVariables = {
39+
AnyVar MassArm ??= DesignVar(2);
40+
AnyString Configuration = CONFIG;
41+
};
3742

38-
43+
ArmModelStudy = {
44+
AnyFolder OutputVariables =
45+
{
46+
AnyVar DeltodeusA = Main.ArmModel.Muscles.DeltodeusA.Activity;
47+
AnyVar DeltodeusB = Main.ArmModel.Muscles.DeltodeusB.Activity;
48+
AnyVar Brachialis = Main.ArmModel.Muscles.Brachialis.Activity;
49+
AnyVar Brachioralis = Main.ArmModel.Muscles.Brachioralis.Activity;
50+
AnyVar BicepsShort = Main.ArmModel.Muscles.BicepsShort.Activity;
51+
AnyVar BicepsLong = Main.ArmModel.Muscles.BicepsLong.Activity;
52+
};
53+
};
3954

40-
55+
4156
// =======================================================
4257
// The Arm Model
4358
// =======================================================
@@ -67,7 +82,7 @@ AnyFolder ArmModel = {
6782
AnySeg UpperArm = {
6883
r0 = {0,0,-0.2};
6984
Axes0 = {{0,0,1},{0,1,0},{-1,0,0}};
70-
Mass = 2.0;
85+
Mass = Main.InputVariables.MassArm;
7186
Jii = {0.005,0.01,0.01};
7287
AnyRefNode ShoulderNode = {
7388
sRel = {-0.2,0,0};
@@ -82,14 +97,16 @@ AnyFolder ArmModel = {
8297
AnyRefNode Brachioradialis = { sRel = {0.05,0,0}; };
8398
AnyRefNode TricepsShort = { sRel = {-0.1,0,0}; };
8499

85-
AnyDrawSeg DrwSeg= {};
100+
viewRefFrame.Visible = On;
101+
viewInertia.Visible = On;
102+
viewNodes.Visible = On;
86103
};
87104

88105
//---------------------------------
89106
AnySeg LowerArm = {
90107
r0 = {0.2,0,-0.4};
91-
Mass = Main.InputVariables.MassArm;
92-
Jii = {0.005,0.01,0.01};
108+
Mass = 1.5;
109+
Jii = Mass*{0.005,0.01,0.01};
93110
AnyRefNode ElbowNode = {
94111
sRel = {-0.2,0,0};
95112
};
@@ -102,7 +119,9 @@ AnyFolder ArmModel = {
102119
AnyRefNode Biceps = { sRel = {-0.15,0,0}; };
103120
AnyRefNode Triceps = { sRel = {-0.25,0,-0.05}; };
104121

105-
AnyDrawSeg DrwSeg= {};
122+
viewRefFrame.Visible = On;
123+
viewInertia.Visible = On;
124+
viewNodes.Visible = On;
106125
};
107126

108127
};
@@ -174,15 +193,22 @@ AnyFolder ArmModel = {
174193
AnyFolder Loads = {
175194

176195
//---------------------------------
196+
#if CONFIG == "Loaded"
177197
AnyForce3D HandLoad = {
178198
AnyRefNode &HandNode = ..Segs.LowerArm.HandNode;
179199
F = {0,0,-100}; // Global force in Newton
200+
viewForce.Visible = On;
201+
202+
203+
AnyFloat FoutTest = Fout;
180204
};
205+
#endif
181206

182207
//---------------------------------
183208
AnyForce ElbowTorque = {
184209
AnyJoint& Jnt = ..Jnts.Elbow;
185210
F = {10}; // Force, equivalent to torque in Newton
211+
viewForce.Visible = On;
186212
};
187213

188214

@@ -198,100 +224,113 @@ AnyFolder ArmModel = {
198224
// We define one simple muscle model, which we will use
199225
// use for all muscles
200226
AnyMuscleModel MusMdl = {
201-
F0 = 300;
227+
F0 = 3000;
202228
};
203229

204230
//---------------------------------
205-
AnyViaPointMuscle DeltodeusA = {
231+
AnyMuscleViaPoint DeltodeusA = {
206232
AnyMuscleModel &MusMdl = .MusMdl;
207233
AnyRefNode &Org = Main.ArmModel.GlobalRef.DeltodeusA;
208234
AnyRefNode &Ins = ..Segs.UpperArm.DeltodeusA;
209-
AnyDrawMuscle DrwMus = {
235+
viewMuscle = {
236+
Visible = On;
210237
RGB = {149/256,51/256,55/256};
211238
Bulging =1.0;
212239
ColorScale =1.0;
213240
RGBColorScale = {0.957031, 0.785156, 0.785156};
214241
MaxStress = 50000; //N/m^2 //This number is for graphics only!
215242
};
243+
216244
};
217245

218246
//---------------------------------
219-
AnyViaPointMuscle DeltodeusB = {
247+
AnyMuscleViaPoint DeltodeusB = {
220248
AnyMuscleModel &MusMdl = .MusMdl;
221249
AnyRefNode &Org = Main.ArmModel.GlobalRef.DeltodeusB;
222250
AnyRefNode &Ins = ..Segs.UpperArm.DeltodeusB;
223-
AnyDrawMuscle DrwMus = {
251+
viewMuscle = {
252+
Visible = On;
224253
RGB = {149/256,51/256,55/256};
225254
Bulging =1.0;
226255
ColorScale =1.0;
227256
RGBColorScale = {0.957031, 0.785156, 0.785156};
228257
MaxStress = 50000; //N/m^2 //This number is for graphics only!
229258
};
259+
230260
};
231261

232262

233263
//---------------------------------
234-
AnyViaPointMuscle Brachialis = {
264+
AnyMuscleViaPoint Brachialis = {
235265
AnyMuscleModel &MusMdl = .MusMdl;
236266
AnyRefNode &Org = ..Segs.UpperArm.Brachialis;
237267
AnyRefNode &Ins = ..Segs.LowerArm.Brachialis;
238-
AnyDrawMuscle DrwMus = {
268+
viewMuscle = {
269+
Visible = On;
239270
RGB = {149/256,51/256,55/256};
240271
Bulging =1.0;
241272
ColorScale =1.0;
242273
RGBColorScale = {0.957031, 0.785156, 0.785156};
243274
MaxStress = 50000; //N/m^2 //This number is for graphics only!
244275
};
276+
245277
};
246278

247279
//---------------------------------
248-
AnyViaPointMuscle Brachioralis = {
280+
AnyMuscleViaPoint Brachioralis = {
249281
AnyMuscleModel &MusMdl = .MusMdl;
250282
AnyRefNode &Org = ..Segs.UpperArm.Brachioradialis;
251283
AnyRefNode &Ins = ..Segs.LowerArm.Brachioradialis;
252-
AnyDrawMuscle DrwMus = {
284+
viewMuscle = {
285+
Visible = On;
253286
RGB = {149/256,51/256,55/256};
254287
Bulging =1.0;
255288
ColorScale =1.0;
256289
RGBColorScale = {0.957031, 0.785156, 0.785156};
257290
MaxStress = 50000; //N/m^2 //This number is for graphics only!
258291
};
292+
259293
};
260294

261295
//---------------------------------
262-
AnyViaPointMuscle BicepsShort = {
296+
AnyMuscleViaPoint BicepsShort = {
263297
AnyMuscleModel &MusMdl = .MusMdl;
264298
AnyRefNode &Org = ..Segs.UpperArm.BicepsShort;
265299
AnyRefNode &Ins = ..Segs.LowerArm.Biceps;
266-
AnyDrawMuscle DrwMus = {
300+
viewMuscle = {
301+
Visible = On;
267302
RGB = {149/256,51/256,55/256};
268303
Bulging =1.0;
269304
ColorScale =1.0;
270305
RGBColorScale = {0.957031, 0.785156, 0.785156};
271306
MaxStress = 50000; //N/m^2 //This number is for graphics only!
272307
};
308+
273309
};
274310

275311
//---------------------------------
276-
AnyViaPointMuscle TricepsShort = {
312+
AnyMuscleViaPoint TricepsShort = {
277313
AnyMuscleModel &MusMdl = .MusMdl;
278314
AnyRefNode &Org = ..Segs.UpperArm.TricepsShort;
279315
AnyRefNode &Ins = ..Segs.LowerArm.Triceps;
280-
AnyDrawMuscle DrwMus = {
316+
viewMuscle = {
317+
Visible = On;
281318
RGB = {149/256,51/256,55/256};
282319
Bulging =1.0;
283320
ColorScale =1.0;
284321
RGBColorScale = {0.957031, 0.785156, 0.785156};
285322
MaxStress = 50000; //N/m^2 //This number is for graphics only!
286323
};
324+
287325
};
288326

289327
//---------------------------------
290-
AnyViaPointMuscle BicepsLong = {
328+
AnyMuscleViaPoint BicepsLong = {
291329
AnyMuscleModel &MusMdl = .MusMdl;
292330
AnyRefNode &Org = Main.ArmModel.GlobalRef.BicepsLong;
293331
AnyRefNode &Ins = ..Segs.LowerArm.Biceps;
294-
AnyDrawMuscle DrwMus = {
332+
viewMuscle = {
333+
Visible = On;
295334
RGB = {149/256,51/256,55/256};
296335
Bulging =1.0;
297336
ColorScale =1.0;
@@ -301,11 +340,12 @@ AnyFolder ArmModel = {
301340
};
302341

303342
//---------------------------------
304-
AnyViaPointMuscle TricepsLong = {
343+
AnyMuscleViaPoint TricepsLong = {
305344
AnyMuscleModel &MusMdl = .MusMdl;
306345
AnyRefNode &Org = Main.ArmModel.GlobalRef.TricepsLong;
307346
AnyRefNode &Ins = ..Segs.LowerArm.Triceps;
308-
AnyDrawMuscle DrwMus = {
347+
viewMuscle = {
348+
Visible = On;
309349
RGB = {149/256,51/256,55/256};
310350
Bulging =1.0;
311351
ColorScale =1.0;
@@ -322,26 +362,10 @@ AnyFolder ArmModel = {
322362
// =======================================================
323363
// "The body study"
324364
// =======================================================
325-
AnyBodyStudy Study = {
365+
AnyBodyStudy ArmModelStudy = {
326366
AnyFolder& Model = Main.ArmModel;
327367
Gravity = {0,0,-9.81};
328-
nStep = 40;
329-
330-
AnyOutputFile FileOutput = {
331-
// Write output to a csv file with the number of steps in filename
332-
FileName = "Output/TestOutput_"+ANYBODY_NAME_MAINFILEDIR+ ".csv";
333-
Header = {
334-
TitleSectionOnOff = Off;
335-
ConstSectionOnOff = Off;
336-
VarSectionOnOff = Off;
337-
ColumnNamesOnOff = On;
338-
};
339-
AnyFloat MaxMusAct = .MaxMuscleActivity;
340-
AnyFloat ElbowAngle = .Model.Drivers.ElbowMotion.Pos;
341-
AnyFloat BicepsLong = .Model.Muscles.BicepsLong.Activity;
342-
};
343-
344-
368+
345369
};
346370

347371

0 commit comments

Comments
 (0)