It looks like you are quite close to the solution. Did you create the output attribute before the code snippet you posted?
AFAttribute att = referenceElement.Attributes.Add("Analysis Output"); att.DataReferencePlugIn = server.DataReferencePlugIns["Analysis"];
Aside from that, it looks like you have the rest of the components required. For reference, this is what I used for mine:
AFAnalysis analysis = new AFAnalysis(db, "Analysis1"); analysis.Target = referenceElement; analysis.AnalysisRulePlugIn = server.AnalysisRulePlugIns["PerformanceEquation"]; AFAnalysisRule arule = analysis.AnalysisRule; arule.ConfigString = "AnalysisOutput := 'CDT' * 2"; arule.MapVariable("AnalysisOutput", "Analysis Output")
This is a good question. Using AF SDK to specify configuration strings is less than ideal, and I highly recommend using PSE instead, as it supports Attribute name resolution and other helpful UI tools. May I ask what your use case is for using AF SDK to create analyses rather than PSE? If you need to create a lot of analyses, I recommend using Element Templates rather than a custom AF SDK solution.
Thank you Martin, your suggertion worked! Yes, I was trying both creating attribute and without creating attribute (hoping to have the functionaliy from PSE, where you do not need to create the attribute, however it seems ok your way). But I was missing setting the attribute DataReferencePlugin. Keith, using PSE is not an option in my case. Does anybody know where can i find some AF Sdk examples for AF Analysis creation?