Message 1 of 1
Failed to open Dotspatial in form from External command.

Not applicable
09-07-2017
07:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Please excuse my poor English.It's not the native language.
Recently I try to connect revit and GIS and RDBMS, which is effective in making work efficiently.
I decided to use dotspatial ,which is a geographic information system library written by C#, (https://dotspatial.codeplex.com/)
In the begging , I tried to open the simple form of dotspatial from External command in Revit.
However It's not working.I paste code and error massage.If someone know the solution and past articles, Please tell me.
Thank you in advance.
GIS_operation.css
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Diagnostics; using IronPython.Hosting; using Microsoft.Scripting.Hosting; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.ApplicationServices; using System.Windows.Forms; namespace Connection_GIS { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] public class GIS_operation : IExternalCommand { /// <summary> /// Revit で他のコマンドや編集モードがアクティブになっていない場合、 /// 登録されている外部コマンドが有効になります。コマンドを選択すると、 /// コマンド オブジェクトが作成され、その Execute()メソッドが呼び出されます。 /// </summary> /// <param name="commandDate">ExternalCommandData オブジェクトは、外部コマンド /// が必要とする Application と View への参照を持ちます。すべての Revit データ /// は外部コマンドのこのパラメータから直接的または間接的に取得されます。</param> /// <param name="message">外部コマンドは出力パラメータ メッセージを使用して、エラ /// ー メッセージを返します。文字列タイプのパラメータは外部コマンド処理で設定されます。</param> /// <param name="elements">Autodesk.Revit.UI.Result.Failed または Autodesk.Revit.UI.Result.Canceled /// が返されたときにパラメータ メッセージが空でない場合は、エラーまたは警告ダイアログ ボックスが表示されます。 /// さらに、要素パラメータに要素が追加されると、これらの要素は画面上でハイライト表示されます</param> /// <returns></returns> public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData commandDate, ref string message, Autodesk.Revit.DB.ElementSet elements) { Autodesk.Revit.UI.TaskDialog.Show("Title", "Now Opening GIS."); System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new Connection_GIS.Form1()); return Autodesk.Revit.UI.Result.Succeeded; } } }
Form1.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.ComponentModel.Composition; using Autodesk.Revit.DB; using Autodesk.Revit.UI; namespace Connection_GIS { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] public partial class Form1 : System.Windows.Forms.Form { [Export("Shell", typeof(ContainerControl))] private static ContainerControl Shell; /// <summary> /// コンストラクタ /// </summary> /// <param name="commandDatax"></param> public Form1() { InitializeComponent(); if (DesignMode) return; Shell = this; appManager1.LoadExtensions(); } private void map1_Load(object sender, EventArgs e) { } } }
Form1.Designer.cs
namespace Connection_GIS { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.appManager1 = new DotSpatial.Controls.AppManager(); this.spatialDockManager1 = new DotSpatial.Controls.SpatialDockManager(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.map1 = new DotSpatial.Controls.Map(); this.legend1 = new DotSpatial.Controls.Legend(); ((System.ComponentModel.ISupportInitialize)(this.spatialDockManager1)).BeginInit(); this.spatialDockManager1.Panel1.SuspendLayout(); this.spatialDockManager1.Panel2.SuspendLayout(); this.spatialDockManager1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.SuspendLayout(); // // appManager1 // this.appManager1.Directories = ((System.Collections.Generic.List<string>)(resources.GetObject("appManager1.Directories"))); this.appManager1.DockManager = this.spatialDockManager1; this.appManager1.HeaderControl = null; this.appManager1.Legend = this.legend1; this.appManager1.Map = this.map1; this.appManager1.ProgressHandler = null; this.appManager1.ShowExtensionsDialogMode = DotSpatial.Controls.ShowExtensionsDialogMode.Default; // // spatialDockManager1 // this.spatialDockManager1.Dock = System.Windows.Forms.DockStyle.Fill; this.spatialDockManager1.Location = new System.Drawing.Point(0, 0); this.spatialDockManager1.Name = "spatialDockManager1"; // // spatialDockManager1.Panel1 // this.spatialDockManager1.Panel1.Controls.Add(this.tabControl1); // // spatialDockManager1.Panel2 // this.spatialDockManager1.Panel2.Controls.Add(this.map1); this.spatialDockManager1.Size = new System.Drawing.Size(1124, 658); this.spatialDockManager1.SplitterDistance = 374; this.spatialDockManager1.TabControl1 = this.tabControl1; this.spatialDockManager1.TabControl2 = null; this.spatialDockManager1.TabIndex = 0; // // tabControl1 // this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(374, 658); this.tabControl1.TabIndex = 0; // // tabPage1 // this.tabPage1.Controls.Add(this.legend1); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); this.tabPage1.Size = new System.Drawing.Size(366, 632); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "tabPage1"; this.tabPage1.UseVisualStyleBackColor = true; // // tabPage2 // this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); this.tabPage2.Size = new System.Drawing.Size(366, 632); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "tabPage2"; this.tabPage2.UseVisualStyleBackColor = true; // // map1 // this.map1.AllowDrop = true; this.map1.BackColor = System.Drawing.Color.White; this.map1.CollectAfterDraw = false; this.map1.CollisionDetection = false; this.map1.Dock = System.Windows.Forms.DockStyle.Fill; this.map1.ExtendBuffer = false; this.map1.FunctionMode = DotSpatial.Controls.FunctionMode.None; this.map1.IsBusy = false; this.map1.IsZoomedToMaxExtent = false; this.map1.Legend = this.legend1; this.map1.Location = new System.Drawing.Point(0, 0); this.map1.Name = "map1"; this.map1.ProgressHandler = null; this.map1.ProjectionModeDefine = DotSpatial.Controls.ActionMode.Prompt; this.map1.ProjectionModeReproject = DotSpatial.Controls.ActionMode.Prompt; this.map1.RedrawLayersWhileResizing = false; this.map1.SelectionEnabled = true; this.map1.Size = new System.Drawing.Size(746, 658); this.map1.TabIndex = 0; this.map1.ZoomOutFartherThanMaxExtent = false; // // legend1 // this.legend1.BackColor = System.Drawing.Color.White; this.legend1.ControlRectangle = new System.Drawing.Rectangle(0, 0, 360, 626); this.legend1.Dock = System.Windows.Forms.DockStyle.Fill; this.legend1.DocumentRectangle = new System.Drawing.Rectangle(0, 0, 187, 428); this.legend1.HorizontalScrollEnabled = true; this.legend1.Indentation = 30; this.legend1.IsInitialized = false; this.legend1.Location = new System.Drawing.Point(3, 3); this.legend1.MinimumSize = new System.Drawing.Size(5, 5); this.legend1.Name = "legend1"; this.legend1.ProgressHandler = null; this.legend1.ResetOnResize = false; this.legend1.SelectionFontColor = System.Drawing.Color.Black; this.legend1.SelectionHighlight = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(238)))), ((int)(((byte)(252))))); this.legend1.Size = new System.Drawing.Size(360, 626); this.legend1.TabIndex = 0; this.legend1.Text = "legend1"; this.legend1.VerticalScrollEnabled = true; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1124, 658); this.Controls.Add(this.spatialDockManager1); this.Name = "Form1"; this.Text = "Form1"; this.spatialDockManager1.Panel1.ResumeLayout(false); this.spatialDockManager1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.spatialDockManager1)).EndInit(); this.spatialDockManager1.ResumeLayout(false); this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.ResumeLayout(false); } #endregion private DotSpatial.Controls.AppManager appManager1; private DotSpatial.Controls.SpatialDockManager spatialDockManager1; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private DotSpatial.Controls.Legend legend1; private System.Windows.Forms.TabPage tabPage2; private DotSpatial.Controls.Map map1; } }
error massage