此處到處是高手,發個很簡單的c#程序,見笑了。
1. 程序說明: 在autocad中打開一個位圖,程序將每一個像素用圓繪制出來。
程序作用:無聊游戲之作,不過也是以前一個位圖矢量化的初步設想,假如對于黑白線條位圖,可用此繪出后,查找圓心,對圓心距離小于sqrt(2)單位的進行連線,以后再進行抽點等操作。當然對于復雜實體和文字等,還需要再尋找算法。
2. 開發平臺 visual studio 2005中文版+ autocad 2007英文版。acmgd.dll等的位置是在d:program filesautocad 2007。
3. 程序使用:用Netload導入form1.dll,然后鍵入命令 my
需要注意的是,由于每個像素繪制一個圓,所以,本程序是沒有圖片大小限制的,但是假若圖片大于250*250像素的時候,需要比較長的時間(我導入的750*350的圖片,大概需要2分鐘,我是P4 2.8G的CPU),會導致CPU運行滿載的情況,請選擇圖片的時候選擇小圖片。
4.一些基本代碼
復制代碼
1. 程序說明: 在autocad中打開一個位圖,程序將每一個像素用圓繪制出來。
程序作用:無聊游戲之作,不過也是以前一個位圖矢量化的初步設想,假如對于黑白線條位圖,可用此繪出后,查找圓心,對圓心距離小于sqrt(2)單位的進行連線,以后再進行抽點等操作。當然對于復雜實體和文字等,還需要再尋找算法。

2. 開發平臺 visual studio 2005中文版+ autocad 2007英文版。acmgd.dll等的位置是在d:program filesautocad 2007。
3. 程序使用:用Netload導入form1.dll,然后鍵入命令 my
需要注意的是,由于每個像素繪制一個圓,所以,本程序是沒有圖片大小限制的,但是假若圖片大于250*250像素的時候,需要比較長的時間(我導入的750*350的圖片,大概需要2分鐘,我是P4 2.8G的CPU),會導致CPU運行滿載的情況,請選擇圖片的時候選擇小圖片。
4.一些基本代碼
- // by qjchen
- // chenqj.blogspot.com
- // 2009-3-27 9:33:23
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using form1;
- namespace form1
- {
- using Autodesk.AutoCAD.Runtime;
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.Colors;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.Geometry;
- using Autodesk.AutoCAD.EditorInput;
- using Autodesk.AutoCAD.Internal;
- using Autodesk.AutoCAD.Interop;
- using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
- public partial class ModalForm : Form
- {
- public ModalForm()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- Bitmap myBitmap = new Bitmap(label1.Text);
- System.Drawing.Color c1;
- int intWidth = myBitmap.Width;
- int intHeight = myBitmap.Height;
- if (intWidth * intHeight > 100000)
- {
- MessageBox.Show("It is a big pic" + intHeight + "," + intWidth);
- }
- for (int i = 0; i <= intWidth - 1; i++)
- {
- for (int j = 0; j <= intHeight - 1; j++)
- {
- this.progressBar1.Value = (int)(i) * 100 / intWidth;
- c1 = myBitmap.GetPixel(i, j);
- int cr = c1.R;
- int cg = c1.G;
- int cb = c1.B;
- ObjectId entId = ModelSpace.AddCircle(new Point3d(i, (intHeight - j), 0), 0.5);
- Database db = HostApplicationServices.WorkingDatabase;
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- Entity ent = (Entity)trans.GetObject(entId, OpenMode.ForWrite);
- ent.Color = Color.FromRgb((byte)cr, (byte)cg, (byte)cb);
- trans.Commit();
- }
- }
- }
- AcadApplication pApp;
- pApp = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
- pApp.ZoomExtents();
- }
- catch { }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofdPic = new OpenFileDialog();
- ofdPic.Filter = "JPG(*.JPG;*.JPEG);gif file(*.GIF);bmp file(*.BMP);png file(*.PNG)|*.jpg;*.jpeg;*.gif;*.bmp;*.png";
- ofdPic.FilterIndex = 1;
- ofdPic.RestoreDirectory = true;
- ofdPic.FileName = "";
- if (ofdPic.ShowDialog() == DialogResult.OK)
- {
- string sPicPaht = ofdPic.FileName.ToString();
- FileInfo fiPicInfo = new FileInfo(sPicPaht);
- long lPicLong = fiPicInfo.Length / 1024;
- string sPicName = fiPicInfo.Name;
- string sPicDirectory = fiPicInfo.Directory.ToString();
- string sPicDirectoryPath = fiPicInfo.DirectoryName;
- Bitmap bmPic = new Bitmap(sPicPaht);
- Point ptLoction = new Point(bmPic.Size);
- if (ptLoction.X > picBox.Size.Width || ptLoction.Y > picBox.Size.Height)
- {
- picBox.SizeMode = PictureBoxSizeMode.Zoom;
- }
- else
- {
- picBox.SizeMode = PictureBoxSizeMode.CenterImage;
- }
- picBox.LoadAsync(sPicPaht);
- label1.Text = sPicDirectoryPath + @"" + sPicName;
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button4_Click(object sender, EventArgs e)
- {
- MessageBox.Show(" To draw bitmap into Autocad by each pixels in circle.n by qjchenn chenqj.blogspot.com");
- }
- [CommandMethod("my")]
- public void drawpic()
- {
- ModalForm modalForm = new ModalForm();
- Application.ShowModalDialog(modalForm);
- }
- }
- }
相關文章
- 2021-09-08BIM技術叢書Revit軟件應用系列Autodesk Revit族詳解 [
- 2021-09-08全國專業技術人員計算機應用能力考試用書 AutoCAD2004
- 2021-09-08EXCEL在工作中的應用 制表、數據處理及宏應用PDF下載
- 2021-08-30從零開始AutoCAD 2014中文版機械制圖基礎培訓教程 [李
- 2021-08-30從零開始AutoCAD 2014中文版建筑制圖基礎培訓教程 [朱
- 2021-08-30電氣CAD實例教程AutoCAD 2010中文版 [左昉 等編著] 20
- 2021-08-30電影風暴2:Maya影像實拍與三維合成攻略PDF下載
- 2021-08-30高等院校藝術設計案例教程中文版AutoCAD 建筑設計案例
- 2021-08-29環境藝術制圖AutoCAD [徐幼光 編著] 2013年PDF下載
- 2021-08-29機械AutoCAD 項目教程 第3版 [繆希偉 主編] 2012年PDF