-
Notifications
You must be signed in to change notification settings - Fork 1
/
KinemeStructureToFile.m
50 lines (42 loc) · 1.18 KB
/
KinemeStructureToFile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#import "KinemeStructureToFile.h"
@implementation KinemeStructureToFile : QCPatch
+ (QCPatchExecutionMode)executionModeWithIdentifier:(id)fp8
{
return kQCPatchExecutionModeConsumer;
}
+ (BOOL)allowsSubpatchesWithIdentifier:(id)fp8
{
return NO;
}
+ (QCPatchTimeMode)timeModeWithIdentifier:(id)fp8
{
return kQCPatchTimeModeNone;
}
- (id)initWithIdentifier:(id)fp8
{
if(self=[super initWithIdentifier:fp8])
{
[inputFile setStringValue:@"~/Desktop/Structure.plist"];
[[self userInfo] setObject:@"Kineme Structure To File" forKey:@"name"];
}
return self;
}
- (BOOL)execute:(QCOpenGLContext *)context time:(double)time arguments:(NSDictionary *)arguments
{
if([inputWriteSignal wasUpdated] && [inputWriteSignal booleanValue] && [inputStructure structureValue] != nil)
{
NSString *path = KIExpandPath(self,[inputFile stringValue]);
if([path length] != 0)
{
NSMutableData *data = [NSMutableData new];
NSKeyedArchiver *coder = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[[inputStructure structureValue] encodeWithCoder:coder];
[coder finishEncoding];
[coder release];
[data writeToFile:path atomically:NO];
[data release];
}
}
return YES;
}
@end