public static ComponentMessage AssembleComponentMessage(Component _comp, MessagePositionInSeq _pos, long _parent_id) { if (_comp == null) { return(null); } if (_comp.R2GInstances == null || _comp.R2GInstances.Count == 0) { return(null); } List <ComponentMessage> messages = new List <ComponentMessage>(); // translate Pt.1 // translate the geometry type(s) Relation2GeomType gr_type_main = Relation2GeomType.NONE; List <InterProcCommunication.Specific.GeometricRelationship> translated_geom_relationships = new List <InterProcCommunication.Specific.GeometricRelationship>(); foreach (ParameterStructure.Geometry.GeometricRelationship gr in _comp.R2GInstances) { Relation2GeomType gr_type = InterProcCommunication.Specific.GeometryUtils.StringToRelationship2Geometry(ParameterStructure.Geometry.GeometryUtils.Relationship2GeometryToString(gr.State.Type)); if (gr_type_main == Relation2GeomType.NONE) { gr_type_main = gr_type; } Relation2GeomState gr_state = new Relation2GeomState { Type = gr_type, IsRealized = gr.State.IsRealized }; InterProcCommunication.Specific.GeometricRelationship gr_translated = new InterProcCommunication.Specific.GeometricRelationship(gr.ID, gr.Name, gr_state, gr.GeomIDs, gr.GeomCS, gr.TRm_WC2LC, gr.TRm_LC2WC, gr.InstanceSize, gr.InstanceNWElementID, gr.InstanceNWElementName, gr.InstancePath); translated_geom_relationships.Add(gr_translated); } // translate Pt.2 // assemble the parameter dictionary according to geometry relationship type Dictionary <string, double> guide = Comp2GeomCommunication.GetReservedParamDictionary(gr_type_main); Dictionary <string, double> p_dict = Comp2GeomCommunication.GetReservedParamDictionary(gr_type_main); foreach (var entry in guide) { Parameter p = _comp.ContainedParameters.Values.FirstOrDefault(x => x.Name == entry.Key); if (p != null) { p_dict[entry.Key] = p.ValueCurrent; } } // done return(new ComponentMessage(_pos, _parent_id, _comp.ID, _comp.IsAutomaticallyGenerated, _comp.CurrentSlot + " " + _comp.Name + " " + _comp.Description, _comp.GetIdsOfAllReferencedComponents(), p_dict, translated_geom_relationships, -1L, -1L, MessageAction.NONE)); }
private void SwitchR2GMainType() { this.R2GInstances[0].State = Relation2GeomState.Next(this.R2GMainState); }