0 Members and 1 Guest are viewing this topic.
[CommandMethod("bmptocad")] public void test() { Bitmap bitmap = new Bitmap("C:\\hal9000.bmp"); Database db = AcAp.Application.DocumentManager.MdiActiveDocument.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { AcDb.BlockTableRecord currentSpace = tr.GetObject (db.CurrentSpaceId, OpenMode.ForWrite) as AcDb.BlockTableRecord; for (int i = 0; i < bitmap.Width; i++) { for (int j = 0; j < bitmap.Height; j++) { DBPoint point = new DBPoint(new Point3d(i,j,0)); point.Color = Autodesk.AutoCAD.Colors.Color.FromColor( bitmap.GetPixel(i,j)); currentSpace.AppendEntity(point); tr.AddNewlyCreatedDBObject(point, true); } } tr.Commit(); } }
nice one dave !
Fairly high C.F.I. (Coolness Factor Index) there Dan.
[CommandMethod("doit")] public void test() { Bitmap bitmap = new Bitmap("C:\\hal9000.bmp"); Database db = AcAp.Application.DocumentManager.MdiActiveDocument.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { AcDb.BlockTableRecord currentSpace = tr.GetObject (db.CurrentSpaceId, OpenMode.ForWrite) as AcDb.BlockTableRecord; for (int i = 0; i < bitmap.Width; i++) { for (int j = 0; j < bitmap.Height; j++) { DBPoint point = new DBPoint(); Autodesk.AutoCAD.Colors.Color color = Autodesk.AutoCAD.Colors.Color.FromColor(bitmap.GetPixel(i, j)); point.Color = color; double z = (color.ColorValue.R + color.ColorValue.G + color.ColorValue.B) * 0.01;//change this point.Position = new Point3d(i, j, z); currentSpace.AppendEntity(point); tr.AddNewlyCreatedDBObject(point, true); } } tr.Commit(); } }
good sh1t Dan :kewl:i'd imagine it bogs acad down a bit though yes?
That is so cool, I don't even have words for it.