Hi all,
I am trying to insert some blocks that i read from CSV file. I am reading the values for X and Y position from a CSV file and inseting blocks with this values in AutoCAD.
Here is my code:
[CommandMethod("BI_5")] public void BlockInsert_5() { String filePath="C:\\Users\\Dimitar\\Desktop\\imp.csv"; CsvDoc csv = new CsvDoc(filePath, true); for (int i = 0; i < csv.Data.Count; i++) { string blockQualifiedFileName = csv.Get<string>(i, "Block Path"); double scale = 3.0; Vector3d DispacementVector = new Vector3d(Double.Parse(csv.Get<string>(i, "PosX")), Double.Parse(csv.Get<string>(i, "PosY")), 0); // Database tmpDb = new Database(false, true); tmpDb.ReadDwgFile(blockQualifiedFileName, System.IO.FileShare.Read, true, ""); Matrix3d Transform = ed.CurrentUserCoordinateSystem; Transform = Transform * Matrix3d.Scaling(scale, Point3d.Origin) * Matrix3d.Displacement(DispacementVector / scale); db.Insert(Transform, tmpDb, true); } }
One of the values for Y is 0. And the block instead of showing on X,0 it shows at some X,Y value. Can you please help me? If you need to see the csv file I can upload it. Thank you in advance.
Best regards,
Dimitar Georgiev
when you do:
Transform = ed.CurrentUserCoordinateSystem * Matrix3d.Scaling(scale, Point3d.Origin) * Matrix3d.Displacement(DispacementVector / scale);
it the same as if you sequentialy first move the block, then scale it and then translate to UCS.
So I have to create ne vector3d, multiply it by the scale and then make it equal to the UCS? I am sorry that i am asking this stupid questions but i just started to learn. If you can explain it I will be very glad.
Thnak you in advance.
I change it to:
Transform = Transform * Matrix3d.Displacement(DispacementVector) * Matrix3d.Scaling(scale, Point3d.Origin);
but still the block that has value 0 for the Y axcis is not on the zero point its lets say with 400 ucs upper form the zero
Ok,
I have a CSV file with blocknames, positionX and positionY fields.
I am reading the file and inserting the blocks. The problem is that the blocks are coming from software where the UCS is set to be on top left part of the screen and the AutoCAD UCS are bottom left. So I have to mirror the image so it can look the same as the original. I am taking the most high number for the height point(positionY) from the existing values and subtracting it from all other values and then I have one element which is with height point 0(meaning positionY=0). I am reading the values and inserting the blocks. All look perfect only one is not on its place it has some value for positionY which does not exist in the value list for positionY. Any ideas why this is happening?
Best regards,
Dimitar Georgiev
Can't find what you're looking for? Ask the community or share your knowledge.