Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to put the data in the block inside the block into a variable and use it in mathematical operations.
Solved! Go to Solution.
I want to put the data in the block inside the block into a variable and use it in mathematical operations.
Solved! Go to Solution.
What have you tried so far? There are several examples in this forum
https://forums.autodesk.com/t5/net/change-block-attribute/m-p/2996912#M23313
You could share the c # code.
You could convert it yourself and learn something along the way?
Read Attributes...
//using acApp = Autodesk.AutoCAD.ApplicationServices.Application; private void GetAttributeValues() { Document doc = acApp.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; TypedValue[] acTypValAr = new TypedValue[1]; acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "INSERT"), 0); SelectionFilter acSelFtr = new SelectionFilter(acTypValAr); using (Transaction acTrans = db.TransactionManager.StartTransaction()) { PromptSelectionResult acSSPrompt; acSSPrompt = ed.SelectAll(acSelFtr); if (acSSPrompt.Status == PromptStatus.OK) { SelectionSet acSSet = acSSPrompt.Value; foreach (SelectedObject acSSObj in acSSet) { if (acSSObj != null) { BlockReference br = (BlockReference)acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForRead); if (br != null) { AttributeCollection attCol = br.AttributeCollection; foreach (ObjectId attId in attCol) { AttributeReference attRef = (AttributeReference)acTrans.GetObject(attId, OpenMode.ForRead); ed.WriteMessage("Attribute Tag: " + attRef.Tag + " | Attribute Text: " + attRef.TextString + "\n"); } } } } } acTrans.Commit(); } }
For dynamic blocks properties...
SelectionSet acSSet = acSSPrompt.Value; foreach (SelectedObject acSSObj in acSSet) { if (acSSObj != null) { BlockReference br = (BlockReference)acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForRead); if (br != null && br.IsDynamicBlock) { DynamicBlockReferencePropertyCollection pc = br.DynamicBlockReferencePropertyCollection; foreach (DynamicBlockReferenceProperty prop in pc) { ed.WriteMessage("Property name: " + prop.PropertyName + " | Property value: " + prop.Value + "\n"); } } } }