I'm looking for a way to create a rule for a part that does not currently exist. Does anyone know of a way to intentionally and directly create an orphan rule using the Intent API?
Matt
There isn't a way to directly do this via the API, but you could create a part, add the dynamic rule, then kill the part.
Actually, as far as i know that won't work either, ETO will automatically prune rules that are inside dynamically created parts.
You would have to use some rule based child for this purpose.
Matt, keep in mind that a child that is an instance of :nulldesign can take dynamic rules. So if the part doesn't "exist" because it is nulled out, you can add dynamic rules without any problem. That could give you options, such as creating your part as a :nulldesign initially, adding the rules, then overwriting the instance with a child that is an instance of the desired design.
Elly
Elly, do you know what triggers Intent to prune orphan rules? I know there is a function that can be called to do it but I haven't run into any cases where it is done automatically. Admittedly I haven't looked too closely either but it certainly doesn't happen when exporting to or importing from IKM/IKP files which in my mind are two obvious points to do it if it is going to be done at all.
The problem is that I need to add the dynamic rules to parts that are at least two layers below the nulldesigned part. So, it seems like my only option is Jack's suggestion to create the entire branch to the desired part using some dummy design and then delete all the parts once the dynamic rules are created.
Matt
well, as I said earlier, that shouldn't work. Intent deletes any dynamic rules within a dynamic branch that is being deleted. Or it should anyway.
So if I create dynamicchild_1, and a dynamic rule 2 levels down called dynamic rule dynamicchild_1.level2.level3.level3dynamicrule, that rule will be deleted along with dynamicchild_1.
Intent does not know to remove dynamic children of branches that are not dynamic. The simples example of this is a child that is a member of a childlist.
Childlistmember_3.level2.level3.leveldynamicrule will not be removed, if the childlist quantity changes to <3.
and of course, the rule is not pruned if the child is nulled out. Which makes sense since it is of course still there, just its design is :nulldesign.
those are cases where the pruning functions can be used.
I am not following why you need to create rules 2 levels down in the first place in advance of the existence of the grandparent. I have seen cases where in conjunction with the grandparent’s creation, we know we have to create lower level rules like these. Is that level 3 also dynamic? if so, using a kind of event cascade can help (Relying on the precreateself() reactor)
elly
Right, we are usually just maniplating child lists or nulldesigning stuff which is why I haven't noticed it happening before. That makes sense.
The core problem is that importing IKM files is broken in Inventor ETO 2013. Performing multiple imports leaves Inventor in an unstable state and it ends up crashing as soon as any part dragging occurs. So far I haven't had any luck with an official fix for this (other than the standard move to 2014 response...) so I'm trying to hack around it by building a custom importer. I think handling orphan rules is the last piece. I'm not 100% convinced that it is crucial but trying to do some CYA in case there is something critical that I'm forgetting about that may depend on keeping the orphan rules.
Matt