protected override void SolveInstance(IGH_DataAccess DA) { GH_AssemblyInfo gsaplugin = Grasshopper.Instances.ComponentServer.FindAssembly(new Guid("a3b08c32-f7de-4b00-b415-f8b466f05e9f")); DA.SetData(0, gsaplugin.Version); DA.SetData(1, gsaplugin.Location); DA.SetData(2, Util.Gsa.InstallationFolderPath.GetPath); }
/// <summary> /// Each implementation of GH_Component must provide a public /// constructor without any arguments. /// Category represents the Tab in which the component will appear, /// Subcategory the panel. If you use non-existing tab or panel names, /// new tabs/panels will automatically be created. /// </summary> public SimpleDynamicLibTestComponent() : base("SimpleDynamicLibTest", "ASpi", "Construct an Archimedean, or arithmetic, spiral given its radii and number of turns.", "Curve", "Primitive") { GH_AssemblyInfo info = Instances.ComponentServer.FindAssembly(new Guid("3a4acc40-c327-4de9-ac25-51b4014c9fd6")); var path = Path.GetDirectoryName(info.Location); libraryHandle = OpenLibrary(path + "/libSimple.dylib"); }
/// <summary> /// Each implementation of GH_Component must provide a public /// constructor without any arguments. /// Category represents the Tab in which the component will appear, /// Subcategory the panel. If you use non-existing tab or panel names, /// new tabs/panels will automatically be created. /// </summary> public LinkageComponentComponent() : base("LinkageComponent", "RodLinkage", "Run deployment simulation.", "XShells", "Linkage Simulation") { GH_AssemblyInfo info = Instances.ComponentServer.FindAssembly(new Guid("b8a730a7-bdde-4d9b-b2b9-ea1b8e126bc2")); var path = Path.GetDirectoryName(info.Location); // Setting the path to the current component directory, therefore `.dylib`s put on the same folder will be discovered. Directory.SetCurrentDirectory(path); }
public ComTypeInfo(IGH_DocumentObject obj) { this.Category = obj.HasCategory ? obj.Category : LanguagableComponent.GetTransLation(new string[] { "<Unnamed Category>", "<未命名类别>" }); this.Subcategory = obj.HasSubCategory ? obj.SubCategory : LanguagableComponent.GetTransLation(new string[] { "<Unnamed Subcategory>", "<未命名子类>" }); this.Name = obj.Name; this.Description = obj.Description; #region Bitmap bitmap = new Bitmap(obj.Icon_24x24, 20, 20); this.Icon = CanvasRenderEngine.BitmapToBitmapImage(bitmap); #endregion this.Exposure = obj.Exposure; this.Guid = obj.ComponentGuid; Type type = obj.GetType(); GH_AssemblyInfo lib = null; Isvalid = true; if (type == null) { this.FullName = ""; } else { this.FullName = type.FullName; lib = GetGHLibrary(type); } this.PluginLocation = lib.Location; this.ShowLocation = this.PluginLocation; this.IsPlugin = !lib.IsCoreLibrary; if (lib != null) { this.AssemblyName = lib.Name; this.AssemblyAuthor = lib.AuthorName; } this.Tip = CreateTip(); }
public ComTypeInfo(IGH_ObjectProxy proxy) { this.Category = proxy.Desc.HasCategory ? proxy.Desc.Category : LanguagableComponent.GetTransLation(new string[] { "<Unnamed Category>", "<未命名类别>" }); this.Subcategory = proxy.Desc.HasSubCategory ? proxy.Desc.SubCategory : LanguagableComponent.GetTransLation(new string[] { "<Unnamed Subcategory>", "<未命名子类>" }); this.Name = proxy.Desc.Name; this.Description = proxy.Desc.Description; #region Bitmap bitmap = new Bitmap(proxy.Icon, 20, 20); this.Icon = CanvasRenderEngine.BitmapToBitmapImage(bitmap); #endregion this.Exposure = proxy.Exposure; this.Guid = proxy.Guid; Isvalid = true; Type type = proxy.Type; GH_AssemblyInfo lib = null; if (type == null) { this.FullName = ""; } else { this.FullName = type.FullName; lib = GetGHLibrary(type); } this.IsPlugin = checkisPlugin(proxy, lib); if (lib != null) { this.AssemblyName = lib.Name; this.AssemblyAuthor = lib.AuthorName; } this.Tip = CreateTip(); }
private bool checkisPlugin(IGH_ObjectProxy proxy, GH_AssemblyInfo lib) { PluginLocation = proxy.Location; if (lib == null) { ShowLocation = PluginLocation; return(true); } string loc2 = lib.Location; if (PluginLocation != loc2) { ShowLocation = loc2 + "\n \n" + PluginLocation; return(true); } else { ShowLocation = PluginLocation; return(!lib.IsCoreLibrary); } }
private void AddOneObject(IGH_DocumentObject obj) { bool showNormal = !normalExceptionGuid.Contains(obj.ComponentGuid); bool showPlugin = !pluginExceptionGuid.Contains(obj.ComponentGuid); if (showNormal) { Font nameFont = new Font(GH_FontServer.Standard.FontFamily, NameBoxFontSize); TextBoxRenderSet nameSet = new TextBoxRenderSet(BackGroundColor, BoundaryColor, nameFont, TextColor); if (this.IsShowName) { Func <SizeF, RectangleF, RectangleF> layout = (x, y) => { PointF pivot = new PointF(y.Left + y.Width / 2, y.Top - NameBoxDistance); return(CanvasRenderEngine.MiddleDownRect(pivot, x)); }; this.RenderObjs.Add(new NickNameOrNameTextBox(this.IsShowNickName, obj, layout, nameSet)); } string cate = IsShowFullCate ? obj.Category : Grasshopper.Instances.ComponentServer.GetCategoryShortName(obj.Category); string subcate = obj.SubCategory; if (this.IsShowCategory) { if (IsMergeCateBox) { string cateName = cate + " - " + subcate; this.RenderObjs.Add(new TextBox(cateName, obj, (x, y) => { PointF pivot = new PointF(y.Left + y.Width / 2, y.Top - NameBoxDistance - ((this.IsShowName ? x.Height : 0) + 3)); return(CanvasRenderEngine.MiddleDownRect(pivot, x)); }, nameSet)); } else { this.RenderObjs.Add(new TextBox(subcate, obj, (x, y) => { PointF pivot = new PointF(y.Left + y.Width / 2, y.Top - NameBoxDistance - ((this.IsShowName ? x.Height : 0) + 3)); return(CanvasRenderEngine.MiddleDownRect(pivot, x)); }, nameSet)); this.RenderObjs.Add(new TextBox(cate, obj, (x, y) => { PointF pivot = new PointF(y.Left + y.Width / 2, y.Top - NameBoxDistance - ((this.IsShowName ? x.Height : 0) + 3) * 2); return(CanvasRenderEngine.MiddleDownRect(pivot, x)); }, nameSet)); } } } if ((this.IsShowAssem) || (this.IsShowPlugin && showPlugin)) { string fullName = ""; string location = ""; Type type = obj.GetType(); if (type != null) { fullName = type.FullName; GH_AssemblyInfo info = null; foreach (GH_AssemblyInfo lib in Grasshopper.Instances.ComponentServer.Libraries) { if (lib.Assembly == obj.GetType().Assembly) { info = lib; break; } } if (info != null) { location = info.Location; if (!info.IsCoreLibrary) { if (IsShowPlugin && showPlugin) { this.RenderObjsUnderComponent.Add(new HighLightRect(obj, PluginHighLightColor, HighLightRadius)); } } } } if (!string.IsNullOrEmpty(fullName) && this.IsShowAssem) { float height = AssemBoxHeight * 14; if (IsAutoAssem) { if (obj is IGH_Component) { IGH_Component com = obj as IGH_Component; height = CanvasRenderEngine.MessageBoxHeight(com.Message, (int)obj.Attributes.Bounds.Width); } else { height = 0; } if (IsAvoidProfiler) { if (height == 0) { height = Math.Max(height, 16); } else { height = Math.Max(height, 32); } } } height += 5; Font assemFont = new Font(GH_FontServer.Standard.FontFamily, AssemFontSize); TextBoxRenderSet assemSet = new TextBoxRenderSet(Color.FromArgb(BackGroundColor.A / 2, BackGroundColor), BoundaryColor, assemFont, TextColor); string fullStr = fullName; if (location != null) { fullStr += "\n \n" + location; } this.RenderObjs.Add(new TextBox(fullStr, obj, (x, y) => { PointF pivot = new PointF(y.Left + y.Width / 2, y.Bottom + height); return(CanvasRenderEngine.MiddleUpRect(pivot, x)); }, assemSet, (x, y, z) => { return(x.MeasureString(y, z, AssemBoxWidth)); }, showFunc: () => { return(obj.Attributes.Selected); })); } } }