.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Please, I have difficulties in handling API AutoCAD.Net using Dynamic Blocks. Could you help me? Thanks in advance.
I'm trying to modify the configuration of a given dynamic block. The goal is to access the property Table1 Block Dynamic Block and change its value to an existing one.
You can navigate between the records from Table1 Block? With this code below I have managed to navigate between the dynamic properties of the block and its values, but I can not make the property value set in the block table1.
I tried an example of the link: http://through-the-interface.typepad...blocks/page
If you have something that can help me I would be very grateful! Attached is a file with dynamic block if you can help me ...
[CommandMethod("getprop")]
static public void GetProps()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions peo =
new PromptEntityOptions("\nSelecione o Bloco: ");
peo.SetRejectMessage("\nIsso não é um Bloco.");
peo.AddAllowedClass(typeof(BlockReference), false);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
ObjectId sourceId = per.ObjectId;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockReference brF =
(BlockReference)tr.GetObject(sourceId, OpenMode.ForRead);
if (brF != null && brF.IsDynamicBlock)
foreach (DynamicBlockReferenceProperty prop in brF.DynamicBlockReferencePropertyCollection)
ed.WriteMessage(string.Format("\n{0}: {1}: ", prop.PropertyName, prop.Value));
tr.Commit();
}
}
Thank you!
Márcio Lourenço Cartacho
C.A.D application Developer
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You have to check IsDynamic property for BlockTableRecord before
[CommandMethod("getprop")]
static public void GetProps()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions peo =
new PromptEntityOptions("\nSelecione o Bloco: ");
peo.SetRejectMessage("\nIsso não é um Bloco.");
peo.AddAllowedClass(typeof(BlockReference), false);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
ObjectId sourceId = per.ObjectId;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockReference brF = (BlockReference)tr.GetObject(sourceId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(brF.BlockTableRecor d, OpenMode.ForRead);
if (btr != null && btr.IsDynamicBlock)
{
foreach (DynamicBlockReferenceProperty prop in brF.DynamicBlockReferencePropertyCollection)
ed.WriteMessage(string.Format("\n{0}: {1}: ", prop.PropertyName, prop.Value));
tr.Commit();
}
}
}
~'J'~
C6309D9E0751D165D0934D0621DFF27919
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thank you for your attention Hallex.
The real objective is modify the value of the property Block Table1.
prop.Value = 3 for example
or
prop.Value= 4 for example or 5, 6, ....
this link show example of how modify this value, but Iam not to apply in my code.
Thanks for your attention.
Márcio Lourenço Cartacho
C.A.D application Developer
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I tried to get values from your drawing,
seems to me next code is working:
[CommandMethod("getprop")]
static public void GetProps()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions peo =
new PromptEntityOptions("\nSelecione o Bloco: ");
peo.SetRejectMessage("\nIsso não é um Bloco.");
peo.AddAllowedClass(typeof(BlockReference), false);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
ObjectId sourceId = per.ObjectId;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockReference brF = (BlockReference)tr.GetObject(sourceId, OpenMode.ForRead);
if (brF.IsDynamicBlock){
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(brF.DynamicBlockTab leRecord, OpenMode.ForRead);
if (btr != null && btr.IsDynamicBlock)
{
foreach (DynamicBlockReferenceProperty prop in brF.DynamicBlockReferencePropertyCollection)
{
ed.WriteMessage(string.Format("\n{0}: {1}: ", prop.PropertyName, prop.Value));
if (prop.PropertyName == "COMPRIMENTO")
{
prop.Value = 1500.0;
}
if (prop.PropertyName == "Distance2")
{
prop.Value = 900.0;
}
// --- change other stuffs here --- //
}
}
tr.Commit();
}
}
}
//Block Table1: 12:
//COMPRIMENTO: 3000:
//Distance2: 118.110236220472:
//Origin: (-1.20792265079217E-13,200,0):
//Visibility1: SEM:
//Desloc: 28.3464566929134:
//Origin: (0,0,0):
//Multi: 121.259842519685:
//Origin: (720,-30.0000000000001,0):
//PISO: 1/4":
~'J'~
C6309D9E0751D165D0934D0621DFF27919
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello,Hallex
The example you sent me worked perfectly. Thank you!
However, when I try to change: if (prop.PropertyName == "Block Table1") {prop.Value = 6;}
generates an error: e.Mensagem: eInvalidInput,
e.StackTrace: at Autodesk.AutoCAD.DatabaseServices.DynamicBlockRefe
I would like to change my Dynamic Block by setting the value of the "Block Table1"
for example:
if (prop.PropertyName == "Block Table1") {prop.Value = 6;}
thanks for the help and attention!!
Márcio Lourenço Cartacho
C.A.D application Developer
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I have never worked with BlockTable, but I will
to try this way,
Later,
~'J'~
C6309D9E0751D165D0934D0621DFF27919
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Ok thank you very much. See this example that I found in LISP program. the program does exactly what I need, but I would like do in C##.NET program.
;(GetBlockValue "Block Table1" 2)
(defun GetBlockValue (prop value)
(vl-load-com)
(setq block (entlast))
(vl-some
(function (lambda ( _prop )
(if (eq prop (strcase (vla-get-propertyname _prop)))
(progn
(vla-put-value _prop (vlax-make-variant value (vlax-variant-type (vla-get-value _prop))))
value
)
)
)
)
(vlax-invoke (vlax-ename->vla-object Block) 'GetDynamicBlockProperties))
)
Márcio Lourenço Cartacho
C.A.D application Developer
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sorry this is out of my skills,
I didn't know how to rich at Block Table rows
using c#
![]()
C6309D9E0751D165D0934D0621DFF27919
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hallex,
Thanks for your attention.
Márcio Lourenço Cartacho
C.A.D application Developer
Re: I have difficulti es in handling API AutoCAD.Ne t using Dynamic Blocks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Márcio,
I suspect the "Block Table1" property cannot be assigned with 6 (integer). Please, inspect its type in your code or in the debugger - prop.PropertyTypeCode, it is a value from this enumeration (described in the ObjectARX Reference Guide):
enum DwgDataType {
kDwgNull = 0,
kDwgReal = 1,
kDwgInt32 = 2,
kDwgInt16 = 3,
kDwgInt8 = 4,
kDwgText = 5,
kDwgBChunk = 6,
kDwgHandle = 7,
kDwgHardOwnershipId = 8,
kDwgSoftOwnershipId = 9,
kDwgHardPointerId = 10,
kDwgSoftPointerId = 11,
kDwg3Real = 12,
kDwgInt64 = 13,
kDwgNotRecognized = 19
};
Marat Mirgaleev
Developer Technical Services
Autodesk Developer Network
