Smart component's attributes via scripting

Ahaaa, I can confirm that now after the file was closed and re-opened, it shows the correct names.
Thanks so much for the info!
I basically used the same code as Rainer posted above.

@GeorgSeifert I cannot find it anywhere here, nor in my emails. But you told me recently how I can access the piece Settings for default/untouched smart components in scripting (obj-c)
So the problem is that when I get the pieceSettings of a component, it only returns the ones that have been modified for the component in that layer. For a particular plugin I need all of them though, similar to the dialogue that appears when the user hits the “Smart” button in the component’s info box.
I tried to search all messages, emails and this forum, I go nuts, I know you put a code snipped somewhere but I am not able to find it.

Here the code for references:

	GSGlyph *ComponentGlyph = [Component component];
	GSLayer *ComponentLayer = [ComponentGlyph layerForKey:[[Component parent] associatedMasterId]];

	GSNotifyingDictionary *PieceSettings = Component.pieceSettings;

	NSMutableDictionary *Defaults = [NSMutableDictionary dictionary];
	for (GSPartProperty *property in ComponentGlyph.partsSettings) {
		Defaults[property.id] = @2;
	}
	[Defaults addEntriesFromDictionary:ComponentLayer.partSelection];

	if (![PieceSettings respondsToSelector:@selector(objectForKey:)]) {
		PieceSettings = [[GSNotifyingDictionary alloc] init];
		Component.pieceSettings = PieceSettings;
	}
	NSMutableArray *Axises = nil;
	NSMutableSet *DisableAxises = [NSMutableSet set];

	if ([ComponentGlyph.partsSettings count] > 0) { //this is a piece
		Axises = [[NSMutableArray alloc] initWithArray:ComponentGlyph.partsSettings copyItems:YES];
		for (GSPartProperty *Axis in Axises) {
			NSNumber *PieceValue = PieceSettings[Axis.id];
			if (PieceValue) {
				Axis.pieceValue = [PieceValue doubleValue];
			}
			else if (Defaults[Axis.id]) {
				if ([Defaults[Axis.id] integerValue] == 1) {
					Axis.pieceValue = Axis.bottomValue;
				}
				else {
					Axis.pieceValue = Axis.topValue;
				}
			}
			else {
				[DisableAxises addObject:Axis.id];
				continue;
			}
			Axis.pieceComponent = (id<GSContainerProtocol>)Component;
		}
	}
1 Like

Thank you!
Wow, that’s quite a mouthful :smiley: