Example #1
0
        private void PrepareMetaLinkData(CyPhy2CAD_CSharp.MetaLinkData data, CyPhyML.ComponentAssembly assembly, String prefix)
        {
            Dictionary <string, CyPhyML.ComponentRef> instanceguids = new Dictionary <string, CyPhyML.ComponentRef>();

            CyphyMetaLinkUtils.CollectInstanceGUIDs(instanceguids, "", assembly);
            if (assembly.Children.ComponentCollection.Any())
            {
                GMEConsole.Warning.WriteLine("Assembly contains components, Meta-Link may not work properly on this model.");
            }
            //List<CyPhyML.ComponentRef> comps = CyphyMetaLinkUtils.CollectComponentRefsRecursive(assembly);
            foreach (var item in instanceguids)
            {
                CyPhy2CAD_CSharp.MetaLinkData.Component mcomp = new CyPhy2CAD_CSharp.MetaLinkData.Component();
                mcomp.ID    = item.Key;
                mcomp.AvmID = (item.Value.AllReferred as CyPhyML.Component).Attributes.AVMID;
                data.Components.Add(mcomp);
                foreach (CyPhyML.Connector conn in (item.Value.AllReferred as CyPhyML.Component).Children.ConnectorCollection)
                {
                    CyPhy2CAD_CSharp.MetaLinkData.Connector mconn = new CyPhy2CAD_CSharp.MetaLinkData.Connector();
                    mconn.ID          = conn.Guid.ToString();
                    mconn.DisplayName = conn.Name;
                    mcomp.Connectors.Add(mconn);
                    foreach (CyPhyML.CADDatum d in conn.Children.CADDatumCollection)
                    {
                        CyPhy2CAD_CSharp.MetaLinkData.Datum md = new CyPhy2CAD_CSharp.MetaLinkData.Datum();
                        md.ID          = d.Guid.ToString();
                        md.DisplayName = d.Name;
                        mconn.Datums.Add(md);
                    }
                }
            }
        }
 private void PrepareMetaLinkData(CyPhy2CAD_CSharp.MetaLinkData data, CyPhyML.ComponentAssembly assembly, String prefix)
 {
     Dictionary<string, CyPhyML.ComponentRef> instanceguids = new Dictionary<string, CyPhyML.ComponentRef>();
     CyphyMetaLinkUtils.CollectInstanceGUIDs(instanceguids, "", assembly);
     if (assembly.Children.ComponentCollection.Any())
     {
         GMEConsole.Warning.WriteLine("Assembly contains components, Meta-Link may not work properly on this model.");
     }
     //List<CyPhyML.ComponentRef> comps = CyphyMetaLinkUtils.CollectComponentRefsRecursive(assembly);
     foreach (var item in instanceguids)
     {
         CyPhy2CAD_CSharp.MetaLinkData.Component mcomp = new CyPhy2CAD_CSharp.MetaLinkData.Component();
         mcomp.ID = item.Key;
         mcomp.AvmID = (item.Value.AllReferred as CyPhyML.Component).Attributes.AVMID;
         data.Components.Add(mcomp);
         foreach (CyPhyML.Connector conn in (item.Value.AllReferred as CyPhyML.Component).Children.ConnectorCollection)
         {
             CyPhy2CAD_CSharp.MetaLinkData.Connector mconn = new CyPhy2CAD_CSharp.MetaLinkData.Connector();
             mconn.ID = conn.Guid.ToString();
             mconn.DisplayName = conn.Name;
             mcomp.Connectors.Add(mconn);
             foreach (CyPhyML.CADDatum d in conn.Children.CADDatumCollection)
             {
                 CyPhy2CAD_CSharp.MetaLinkData.Datum md = new CyPhy2CAD_CSharp.MetaLinkData.Datum();
                 md.ID = d.Guid.ToString();
                 md.DisplayName = d.Name;
                 mconn.Datums.Add(md);
             }
         }
     }
 }