TheSwamp
Code Red => .NET => Topic started by: It's Alive! on April 03, 2008, 02:16:06 AM
-
:-D
[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 !
:-)
-
nice one dave !
:-)
Thanks KB just having a little fun :laugh:
-
Fairly high C.F.I. (Coolness Factor Index) there Dan.
-
Fairly high C.F.I. (Coolness Factor Index) there Dan.
Thanks Glenn :-)
I need to reverse the scan so the picture comes in right side up, I was also thinking it might be fun to place the point Z based on color Ie. Lighter colors would have a higher elevation.
-
Wow cool :-D
[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?
-
good sh1t Dan :kewl:
i'd imagine it bogs acad down a bit though yes?
hehe Not too bad on small images, don’t go loading a 5 mega pixel pic though :lol:
-
and triangulated :laugh:
-
That is so cool, I don't even have words for it.
-
That is so cool, I don't even have words for it.
Thanks Chuck,
While it’s much prettier than my Morse code lisp routine, it probably just a useful :laugh:
-
Image "binding" anyone?
-
thaaaaat's probably one of the cooler things I've seen in a while! lol
-
nice you made the "Heightfield" command
-
Nice work
I've been pondering something similar using tiffs
-
i know i'm asking a rather stupid question, but how do you use that coding. it's actually quite useful, i just don't understand what to do with the coding to get it to work.
-
yes bmp jpg pcx png and tiff are supported
-
:-D
[CommandMethod("bmptocad")]
Very cool Daniel! Did you notice the image is flipped upside down?
-
changing this line
DBPoint point = new DBPoint(new Point3d(i,j,0));
to
DBPoint point = new DBPoint(new Point3d(i,0-j,0));
seems to be a fix.
-
hehehehe
http://www.objectarx.net/bbs/viewthread.php?tid=1766&extra=page%3D1
added
Reads in a BMP document to see to AutoCAD in at a foreigner's forum,
may read a BMP document in AutoCAD.
-
hehehehe
http://www.objectarx.net/bbs/viewthread.php?tid=1766&extra=page%3D1
added
Reads in a BMP document to see to AutoCAD in at a foreigner's forum,
may read a BMP document in AutoCAD.
Well, hot dang, I have finally written code that’s good enough to be …
-
changing this line
DBPoint point = new DBPoint(new Point3d(i,j,0));
to
DBPoint point = new DBPoint(new Point3d(i,0-j,0));
seems to be a fix.
Awesome, Thank you! :-)
-
Daniel, cool stuff for sure.
管理员
帖子794 精华1 积分4451 来自中国 个人空间 发
-
I want to try this, but how do create the command in CAD?
-
i know i'm asking a rather stupid question, but how do you use that coding. it's actually quite useful, i just don't understand what to do with the coding to get it to work.
I have attached a DLL that you can netload into AutoCAD and execute through lisp I.E
(BMPToCad "c:\\hal9000.bmp" 0)