BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Archicad C++ API
About Archicad add-on development using the C++ API.

Override rules creation

Anonymous
Not applicable
Hi,

I am digging in the Override_Test example project to see what the API lets us do in this field.
I am very surprised to realize that rules creation implies creating manually then saving their criterions as an XML string.
API_OverrideRule rule;
	rule.name = "Transparent surface for Windows and Doors";

	// NOTE: to get the proper criterion XML, go to ARCHICAD and save the wanted override rule as XML
	// Criterion XML: Element Type is Window or Door
	rule.criterionXML =
		"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"
		"<CriterionExpression Mv=\"2\" Sv=\"1\">"
			"<TextMatchType>1</TextMatchType>"
			"<Size>1</Size>"
			"<ClassGuid>C6EBD1BD-7702-46FF-8ED9-9CC37648A7C7</ClassGuid>"
			"<CompositeCriterion Mv=\"2\" Sv=\"1\">"
				"<LogicalOperator>2</LogicalOperator>"
				"<CriteriaCount>1</CriteriaCount>"
				"<ClassGuid>C6EBD1BD-7702-46FF-8ED9-9CC37648A7C7</ClassGuid>"
				"<CompositeCriterion Mv=\"2\" Sv=\"1\">"
					"<LogicalOperator>1</LogicalOperator>"
					"<CriteriaCount>2</CriteriaCount>"
					"<ClassGuid>B4B7B134-EC56-4D40-8D4C-71D7C5A2493A</ClassGuid>"
					"<ElemTypeCriterion Mv=\"2\" Sv=\"3\">"
						"<VBEF::CritToolType Mv=\"1\" Sv=\"0\">"
							"<ElemRegistryRefId>1464421956</ElemRegistryRefId>"
							"<ElemCreatorToolUnID>"
								"<MainGuid>4ABD0A6E-634B-4931-B3AA-9BEE01F35CDF</MainGuid>"
								"<RevGuid>5585F21A-DE1C-164C-A64E-92CB48F79FA5</RevGuid>"
							"</ElemCreatorToolUnID>"
						"</VBEF::CritToolType>"
						"<LogicalOperator>1</LogicalOperator>"
					"</ElemTypeCriterion>"
					"<ClassGuid>B4B7B134-EC56-4D40-8D4C-71D7C5A2493A</ClassGuid>"
					"<ElemTypeCriterion Mv=\"2\" Sv=\"3\">"
						"<VBEF::CritToolType Mv=\"1\" Sv=\"0\">"
							"<ElemRegistryRefId>1146048338</ElemRegistryRefId>"
							"<ElemCreatorToolUnID>"
								"<MainGuid>11E85B84-8DD1-491B-A2FE-337454A91545</MainGuid>"
								"<RevGuid>91A61E93-32A8-BC46-A11A-5FB89256C651</RevGuid>"
							"</ElemCreatorToolUnID>"
						"</VBEF::CritToolType>"
						"<LogicalOperator>1</LogicalOperator>"
					"</ElemTypeCriterion>"
				"</CompositeCriterion>"
			"</CompositeCriterion>"
		"</CriterionExpression>";
I wanted to create this kind of "filters" automatically in my add-on.

Thanks for your ideas.
12 REPLIES 12
Regina Judak
Graphisoft Alumni
Graphisoft Alumni
Hi,

Maybe I don’t understand the problem well, so is the problem that at the code there is that note, which says you should save the XML from ARCHICAD and instead of that you would like to do this from your addon automatically? If this is the case, I think you can do it from the code, the comment just say that if you save it from ARCHICAD than the fromat of the XML will be surely in the correct form.

Best, Regina
Anonymous
Not applicable
Hi,

Thanks for your answer.

I can't figure out how to easily create this kind of XML string in my code...
How am I supposed to know what to put for instance in the CompositeCriterion attributes (Mv, Sv) or in LogicalOperator (what corresponds to 1,2, etc) ?

Are there any guidelines to build the XML criterion ? Has ever someone tried to do it by the code ?
Regina Judak
Graphisoft Alumni
Graphisoft Alumni
Hi,
I asked about it from one of my colleagues. Now there is no detailed documentation about this XML creation and the recommended way to use it is that to save the XML from the ARCHICAD.
Is there any specific reason why you would like to create this XML from your code? We would like to know better how developers want to use this feature in order to think about how we can improve it in the future.
Thanks!
Regina
Anonymous
Not applicable
Hi,

I would like to automize the creation of filtered views, based on some user settings (parameters to filter, initial views to copy, ...) so I need a way to represent/declare a filter criterion with the API.

Maxime
Akos Somorjai
Graphisoft
Graphisoft
mvallee wrote:
Hi,

I would like to automize the creation of filtered views, based on some user settings (parameters to filter, initial views to copy, ...) so I need a way to represent/declare a filter criterion with the API.

Maxime
Then I would recommend setting up one filtered view manually, export that as XML, then use that XML as a template to create other views.

Best, Akos
Anonymous
Not applicable
The idea was to do all the work automatically for the user, not to force him to start by creating a filter manually.

Even if I ask him to do it, how am I supposed to know how to modify this XML criterion later, if there is no doc about it ?

To be clearer I want the user to select in my UI :
1) Archicad objects categories (walls, doors)
2) a parameter of that/these category(ies) to analyse
3) some initial views to copy

Then the plugin would create copies of the selected views, then create and apply on the copies some colored filters to represent each detected value for the selected parameter.

With the current state of things, it seems quite impossible to achieve that, doesn't it ?
Akos Somorjai
Graphisoft
Graphisoft
mvallee wrote:
The idea was to do all the work automatically for the user, not to force him to start by creating a filter manually.

Even if I ask him to do it, how am I supposed to know how to modify this XML criterion later, if there is no doc about it ?

To be clearer I want the user to select in my UI :
1) Archicad objects categories (walls, doors)
2) a parameter of that/these category(ies) to analyse
3) some initial views to copy

Then the plugin would create copies of the selected views, then create and apply on the copies some colored filters to represent each detected value for the selected parameter.

With the current state of things, it seems quite impossible to achieve that, doesn't it ?
Hi,

It seems to be possible, but there's no easy way, because you have to figure out the mapping of each and every parameter beforehand. For that I would create a specific rule for every element type by hand, dump the rule to an XML file, and create a mapping out of that, which can be used later to construct the filters you want.

Best, Akos
Anonymous
Not applicable
Akos wrote:
mvallee wrote:
The idea was to do all the work automatically for the user, not to force him to start by creating a filter manually.

Even if I ask him to do it, how am I supposed to know how to modify this XML criterion later, if there is no doc about it ?

To be clearer I want the user to select in my UI :
1) Archicad objects categories (walls, doors)
2) a parameter of that/these category(ies) to analyse
3) some initial views to copy

Then the plugin would create copies of the selected views, then create and apply on the copies some colored filters to represent each detected value for the selected parameter.

With the current state of things, it seems quite impossible to achieve that, doesn't it ?
Hi,

It seems to be possible, but there's no easy way, because you have to figure out the mapping of each and every parameter beforehand. For that I would create a specific rule for every element type by hand, dump the rule to an XML file, and create a mapping out of that, which can be used later to construct the filters you want.

Best, Akos
Ok, but do you have a document that explains how the XML data is written ? Without it, the work is going to be very difficult.
Akos Somorjai
Graphisoft
Graphisoft
mvallee wrote:
Ok, but do you have a document that explains how the XML data is written ? Without it, the work is going to be very difficult.
I'm sorry, but we don't have any documentation on that.

Best, Akos
Learn and get certified!