0

I am absolute noob in this area but I decided to do something with it. I'd like to achieve this: there is a drawing with a geometry - lets say a circle - and attribute definition. What I like to do is to scale everything in the drawing by 2 and additionaly to move attribute to nearest grid point (if an attribute definition is located in [10.1,14.9] it should be moved to [10,15]. To be honest I know how to create new simple objects, but I dont know how to handle existing stuff and have no idea how to query location from attribute definitions.

Any help appreciated! Thanks!

ps: VS2013/ACAD2015

example drawings in 2010/2013 format:

http://www40.zippyshare.com/v/37899772/file.html

http://www40.zippyshare.com/v/83044603/file.html

UPDATE: I made some progress on this issue. The scaling was done by using command:

acDoc.SendStringToExecute("_ai_selall\n", true, false, false);
acDoc.SendStringToExecute("scale\n", true, false, false);
acDoc.SendStringToExecute("0,0\n", true, false, false);
acDoc.SendStringToExecute("2\n", true, false, false);

Then I did an iterate through Block Table Record (looking for ATTDEF):

BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
foreach (ObjectId acObjId in acBlkTblRec) { ... } etc.

And at the end I expected to save modified file (again through SendStringToExecute).

acDoc.SendStringToExecute("qsave\n", true, false, false);
acDoc.SendStringToExecute("close\n", true, false, false);

However it doesn't work as I'd though it will. As I planned to process a list of files it starts to open file by file, do something with that but not in order it suppose to do. It opens the file then process of scaling and fixing the location of attributes is mixed(!). I found out it has something to do with SendStringToExecute/Autocad.

So now I have to find out how to keep my sequence as I planned.

krn
  • 3
  • 4
  • Without clicking on the dubious links... When you create the objects, you need to store them in a list somewhere, and then draw from the list – Sayse Apr 17 '14 at 15:01
  • You're more likely to get help if you narrow your question to a specific problem and post some code that demonstrates what you tried, what you expected, and how it failed. – Owen Wengerd Apr 25 '14 at 03:59
  • Following on from list suggestion, you would then need to call Math.Floor(10.1) for example, to get your "nearest grid point" – reckface May 05 '14 at 11:54
  • Thank you, for your comments. Yes, I realize my question was too general, I had zero knowledge in that area. Since then I learnt something but still see some obstacles. Thanks @reckface, I used Math.Round(X) in my code. it seems it better suits my needs :) – krn May 07 '14 at 10:09

0 Answers0