c# 根据CAD权籍数据的扩展属性,输出房地一体资料,申请表、审批表等

c# 根据CAD权籍数据的扩展属性,输出房地一体资料,申请表、审批表等
using System;
using System.Windows.Forms;
using MSWord = Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;
using System.Reflection;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using cadapp = Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using Autodesk.AutoCAD.Interop;
using System.Drawing;
using Autodesk.AutoCAD.Interop.Common;
using System.Collections.Generic;
using System.Linq;
namespace _10_输出房地一体资料
{
public partial class Form1 : Form
{

    public Form1()
    {
        
        InitializeComponent();
        bdcdyh.Text = "";
        zl.Text = "";
        qlrmc.Text = "";
        dhhm.Text = "";
        zjh.Text = "";
        zcs.Text = "3";
        zdmj.Text = "160.62";
        jzzdmj.Text = "160.62";
        jzmj.Text = "425.42";
        cwh.Text = "";
        szb.Text = "";
        szd.Text = "";
        szn.Text = "空地";
        szx.Text = "空地";
        txdz.Text = "";
        fwjg.Text = "钢筋混凝土";
        jgsj.Text = "2008年07月09日";
        zjsj.Text = "2008年07月09日";

    }

    private void button1_Click(object sender, EventArgs e)
    {
        string bdcdyh1 = bdcdyh.Text;
        string zl1 = zl.Text;
        string qlrmc1 = qlrmc.Text;
        string dhhm1 = dhhm.Text;
        string zjh1 = zjh.Text;
        string zcs1 = zcs.Text;
        string zdmj1 = zdmj.Text;
        string jzzdmj1 = jzzdmj.Text;
        string jzmj1 = jzmj.Text;
        string cwh1 = cwh.Text;
        string szb1 = szb.Text;
        string szd1 = szd.Text;
        string szn1 = szn.Text;
        string szx1 = szx.Text;
        string txdz1 = txdz.Text;
        string fwjg1 = fwjg.Text;
        string jgsj1 = jgsj.Text;
        string zjsj1 = zjsj.Text;
        output_sqb(bdcdyh1, qlrmc1, zl1, dhhm1, zjh1, jgsj1, zdmj1);
    }

    private void output_sqb(string bdcdyh1, string qlrmc1, string zl1, string dhhm1, string zjh1, string jgsj1, string zdmj1
        )
    {
        bdcdyh.Text = bdcdyh1 + "ye";
        object path;
        string strContent;
        MSWord.Application wordApp;
        MSWord.Document wordDoc;
        path = @"D:\2-python\10-精测房地数据转换程序\源代码\temp\updatefdyt\不动产调查登记申请表 - 副本.docx";
        wordApp = new MSWord.Application(); //初始化

        wordApp.Visible = false;//使文档可见
        Object Nothing = Missing.Value;
        wordDoc = wordApp.Documents.Add(path);
        var table = wordDoc.Tables[3] as MSWord.Table;
        table.Cell(1,2).Range.Text = bdcdyh1.Substring(0,19);
        table.Cell(1,4).Range.Text = bdcdyh1.Substring(0, 19);
        table.Cell(2, 2).Range.Text = bdcdyh1;
        table.Cell(6, 4).Range.Text = dhhm1;
        table.Cell(11, 2).Range.Text = zl1;
        //写入权利人信息
        string[] list_qlrmc = qlrmc1.Split('、');
        string[] list_zjh = zjh1.Split('、');
        for (int i = 0; i < list_qlrmc.Length; i++)
        {
            if (i == 4) break;
            if (i==0)
            {
                table.Cell(3, 2).Range.Text = list_qlrmc[i];
                table.Cell(5, 4).Range.Text = list_zjh[i];
            }
            else
            {
                table.Cell(15 + i, 2).Range.Text = list_qlrmc[i];
                table.Cell(15 + i, 3).Range.Text = "个人";
                table.Cell(15 + i, 4).Range.Text = "身份证";
                table.Cell(15 + i, 5).Range.Text = list_zjh[i];
            }
        }
        table.Cell(21, 4).Range.Text = zdmj1;
        table.Cell(21, 6).Range.Text = jgsj1;
        wordDoc.SaveAs("D:\\2-python\\10-精测房地数据转换程序\\源代码\\temp\\updatefdyt\\Test.docx");
        wordApp.Quit();
        //bdcdyh.Text = str1;
    }

    private void button2_Click(object sender, EventArgs e)
    {
        AcadApplication app = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.23");
        AcadDocument doc = app.ActiveDocument;
        //Editor ed = cadapp.Core.Application.DocumentManager.MdiActiveDocument.Editor;
        //PromptEntityOptions opt = new PromptEntityOptions("\n 请选择实体:");
        //PromptEntityResult res = ed.GetEntity(opt);
        //double[] spoint = { 0, 0, 0 };
        //double[] epoint = { 0, 1000, 0 };
        //doc.ModelSpace.AddLine(spoint, epoint);
        //app.ZoomAll();
        object returnObj, pickPoint;
        string pickPrompt = "请选择Excel数据对象或者CAD表格对象:";
        doc.Utility.GetEntity(out returnObj, out pickPoint, pickPrompt);
        AcadObject returnCADObj = (AcadObject)returnObj;
        //foreach (var item in pickPrompt)
        //{

        //}
        object returnObj1, pickPoint1;
        returnCADObj.GetXData("BDMAP_ZDBASEATT", out returnObj1, out pickPoint1);
        Type t = pickPoint1.GetType();
        IEnumerable<System.Reflection.PropertyInfo> property = from pi in t.GetProperties() where pi.Name.ToLower() == "1".ToLower() select pi;
        string a = property.First().GetValue(pickPoint1, null);
        //AcadToolbar tool = app.MenuGroups.Item(0).Toolbars.Add("test");
        //AcadToolbarItem tbaritem = tool.AddToolbarButton(0, "mycommand1", "new line", "L ", false);
        //tbaritem.SetBitmaps("Small iconname ", "Big iconname ");
        //Console.ReadLine();
    }
    private void dhhm_TextChanged(object sender, EventArgs e)
    {

    }
}

}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DK业

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值