Good Day,
I'm crafting a csharp programme through visual studio to calculate invert levels in autocad and insert a block with that level automatically added. Then repeat the calcs and insertion at any point the user clicks on until the programme is cancelled.
The calculations are complete but I'm having problems inserting the block. I'm trying to pull the block (Level_Arrow) from another drawing (C:\Test.dwg) to be placed at the target point (ptInsert) with block scale (drgScale), rotation 0 and (ptDisp) as first attribute, " " as second attribute (or nothing).
Is there a simple and easy way of doing this?
Please note, I have experience with Lisp but little experience with Csharp. If your answer could be simple and well explained I would be grateful.
Thank you,
Solved! Go to Solution.
Solved by BlackBox_. Go to Solution.
@Anonymous wrote:Good Day,
I'm crafting a csharp programme through visual studio to calculate invert levels in autocad and insert a block with that level automatically added. Then repeat the calcs and insertion at any point the user clicks on until the programme is cancelled.
The calculations are complete but I'm having problems inserting the block. I'm trying to pull the block (Level_Arrow) from another drawing (C:\Test.dwg) to be placed at the target point (ptInsert) with block scale (drgScale), rotation 0 and (ptDisp) as first attribute, " " as second attribute (or nothing).
Is there a simple and easy way of doing this?
Please note, I have experience with Lisp but little experience with Csharp. If your answer could be simple and well explained I would be grateful.
Thank you,
Here's a snippet from a project that is copying attribute values from one block to another; complete Transaction not shown here:
// ... Dictionary<string, string> d = new Dictionary<string, string>(); AttributeCollection ac = block.AttributeCollection; foreach (ObjectId attId in ac) { AttributeReference attRef = (AttributeReference)tr.GetObject(attId, OpenMode.ForRead); if (!d.ContainsKey(attRef.Tag)) { d.Add(attRef.Tag, attRef.TextString); } } // <-- add your new BlockReference() here foreach (ObjectId x in <YourNewBlockHere>) { AttributeDefinition ad = tr.GetObject(x, OpenMode.ForRead) as AttributeDefinition; if (ad != null) { AttributeReference ar = new AttributeReference(); ar.SetAttributeFromBlock(ad, t); ar.Position = ad.Position.TransformBy(t); ar.TextString = d[ar.Tag]; } } // ...
Cheers
"How we think determines what we do, and what we do determines what we get."