CAD/CAM discussion forum > CAD > Working with dynamic blocks with .NET API

Working with dynamic blocks with .NET API

Rank: 1

carlos6209

Newbie

posts: 4

Registered: 2014-4-2

Message 1 of 3

 Working with dynamic blocks with .NET API
04-04-2014 05:05 . pm | View his/her posts only
Hello,

In my company, we are evaluating the ZwCAD as an alternative to AutoCAD and we use very dynamic blocks. We have a lot of code C#.NET working in AutoCAD, I already migrated to ZwCAD but there are problems in dynamic blocks.:

1. How to get the name of an anonymous block?
Code used and working in autoCAD for this purpose (does not work in ZwCAD)

blockreference = (BlockReference)transition.GetObject(objectid, OpenMode.ForRead);
if (blockreference.IsDynamicBlock)
blockname = ((BlockTableRecord)transition.GetObject(blockreference.DynamicBlockTableRecord, OpenMode.ForRead)).Name;
else
blockname = ((BlockTableRecord)transition.GetObject(blockreference.BlockTableRecord, OpenMode.ForRead)).Name;


( blockreference.DynamicBlockTableRecord return nothing/null )

2. How to list all references of a block definition by the name if the block are dynamic?
Code used in autoCAD for this purpose (does not work in ZwCAD)

BlockTable blocktable = (BlockTable)transaction.GetObject(database.BlockTableId, OpenMode.ForRead); if (blocktable.Has(blockname))
{
BlockTableRecord blocktablerecord = (BlockTableRecord)transaction.GetObject(blocktable[blockname], OpenMode.ForRead, false, false);

ObjectIdCollection allblockreferences =
blocktablerecord.GetBlockReferenceIds(true, true);

foreach (ObjectId auxreferenceid in
allblockreferences)
blocksreferencesbyname.Add(auxReferenceId); //add to a list of objects ids

if (blocktablerecord.IsDynamicBlock)

{
//ObjectIdCollection blockanonymousreferences = blocktablerecord.GetAnonymousBlockIds();


//foreach (ObjectId anonyreferenceid in blockanonymousreferences)
//{
// blocktablerecord = (BlockTableRecord)transaction.GetObject(
anonyreferenceid, OpenMode.ForRead, false, false);


// blockreferences = blocktablerecord.GetBlockReferenceIds(true, true);

// foreach (ObjectId auxreferenceid in blockreferences)
// if (!BlocksReferencesByName.Contains(auxreferenceid))
// BlocksReferencesByName.Add(
auxreferenceid);
//}
}
}


( the commented part is because the non implementation of blocktablerecord.GetAnonymousBlockIds() )

3. I know that is not possible to get or set dynamic properties, when you think this is implemented in the api. NET?


This all is crucial to my business.

(Sorry my English)

Thanks.

Rank: 1

carlos6209

Newbie

posts: 4

Registered: 2014-4-2

Message 2 of 3

07-04-2014 05:46 . pm | View his/her posts only
Hi,
I need help from ZwCAD support to this problem, please help.

Rank: 1

carlos6209

Newbie

posts: 4

Registered: 2014-4-2

Message 3 of 3

15-04-2014 05:21 . pm | View his/her posts only
Reply 2# carlos6209


To ZwCAD support:

Please answer something, at least that's impossible and I start test other AutoCAD alternatives.
See also