.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Property Sheet

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
308 Views, 3 Replies

Custom Property Sheet

Hi,

I am working on a program in AutoCAD 2008 to populate the Custom property
sheet fields with attribute tag names and values read from a title block.

The problem that I am having is when the attribute tag names are written to
the Custom property sheet "Name" fields they are written in lower-case even
though they are defined in the block as upper-case. I have tried forcing the
attribute tag names to upper-case which has no affect.

So, I am at a loss. Does anyone have any ideas?

Below is my work in progress program. I have also included a screen capture
of the Custom property sheet after it has been populated.

namespace Engineering
{
public class EngineeringCommands
{
[CommandMethod("UPS")]
public static void UpdatePropertySheet()
{
Database db = HostApplicationServices.WorkingDatabase;
DatabaseSummaryInfo dbSummaryInfo;
DatabaseSummaryInfoBuilder dbSummaryInfoBuilder =
new DatabaseSummaryInfoBuilder();

using (Transaction tr =
db.TransactionManager.StartTransaction())
{
BlockTable bt =
tr.GetObject(db.BlockTableId, OpenMode.ForRead)
as BlockTable;

string titleBlock = "22X34";
if (bt.Has(titleBlock))
{
BlockTableRecord btr =
tr.GetObject(bt[titleBlock], OpenMode.ForRead)
as BlockTableRecord;
if (btr != null)
{
ObjectIdCollection objIdCol =
btr.GetBlockReferenceIds(true, true);
if (objIdCol.Count == 1)
{
BlockReference br =
tr.GetObject(objIdCol[0], OpenMode.ForRead)
as BlockReference;
if (br != null)
{
foreach (ObjectId attId in
br.AttributeCollection)
{
AttributeReference ar =
tr.GetObject(attId,
OpenMode.ForRead)
as AttributeReference;

dbSummaryInfoBuilder.CustomProperties.Add(ar.Tag,
ar.TextString);
// For AutoCAD 2009, delete the
statement
// above and uncomment the statement
below.
//dbSummaryInfoBuilder.CustomPropertyTable.Add(ar.Tag,
ar.TextString);
}
dbSummaryInfo =
dbSummaryInfoBuilder.ToDatabaseSummaryInfo();
HostApplicationServices.WorkingDatabase.SummaryInfo
= dbSummaryInfo;
}
}
}
}
tr.Commit();
}
}
}
}
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Oh what a mess! I just viewed my posting through my news reader.

"Nick Schuckert" wrote in message
news:6077928@discussion.autodesk.com...
Hi,

I am working on a program in AutoCAD 2008 to populate the
Custom property
sheet fields with attribute tag names and values read
from a title block.

The problem that I am having is when the
attribute tag names are written to
the Custom property sheet "Name"
fields they are written in lower-case even
though they are defined in
the block as upper-case. I have tried forcing the
attribute tag names
to upper-case which has no affect.

So, I am at a loss. Does
anyone have any ideas?

Below is my work in progress program. I
have also included a screen capture
of the Custom property sheet after
it has been populated.

namespace Engineering
{

public class EngineeringCommands
{

[CommandMethod("UPS")]
public static void
UpdatePropertySheet()
{
Database db =
HostApplicationServices.WorkingDatabase;

DatabaseSummaryInfo dbSummaryInfo;

DatabaseSummaryInfoBuilder dbSummaryInfoBuilder =
new
DatabaseSummaryInfoBuilder();

using (Transaction tr =

db.TransactionManager.StartTransaction())
{

BlockTable bt =
tr.GetObject(db.BlockTableId,
OpenMode.ForRead)
as BlockTable;


string titleBlock = "22X34";
if (bt.Has(titleBlock))

/> {
BlockTableRecord btr =

tr.GetObject(bt[titleBlock], OpenMode.ForRead)

as BlockTableRecord;
if (btr != null)

{
ObjectIdCollection objIdCol =

btr.GetBlockReferenceIds(true, true);
if
(objIdCol.Count == 1)
{

BlockReference br =

tr.GetObject(objIdCol[0], OpenMode.ForRead)

as BlockReference;
if (br != null)

{
foreach (ObjectId attId in

/>br.AttributeCollection)
{

AttributeReference ar =

tr.GetObject(attId,
OpenMode.ForRead)

as AttributeReference;


dbSummaryInfoBuilder.CustomProperties.Add(ar.Tag,
ar.TextString);

/> // For AutoCAD 2009, delete the

/>statement
// above and uncomment
the statement
below.

//dbSummaryInfoBuilder.CustomPropertyTable.Add(ar.Tag,

/>ar.TextString);
}

dbSummaryInfo =
dbSummaryInfoBuilder.ToDatabaseSummaryInfo();

HostApplicationServices.WorkingDatabase.SummaryInfo
=
dbSummaryInfo;
}

}
}
}

tr.Commit();
}
}
}
}
Message 3 of 4
Anonymous
in reply to: Anonymous


The issue has been discussed here before and
reported.

 

I haven't checked if it was addressed in
AutoCAD 2009.

 

They didn't do a very good job on that, and there's no known

workaround for it. They unwisely used a StringDictionary
for

storing the data, and it always converts its keys to
lowercase.

 


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Oh
what a mess! I just viewed my posting through my news reader.

"Nick
Schuckert" <
href="mailto:nospam_NickSchuckert@Comcast.net">nospam_NickSchuckert@Comcast.net
>
wrote in message

href="news:6077928@discussion.autodesk.com">news:6077928@discussion.autodesk.com
...
Hi,<br
/><br />I am working on a program in AutoCAD 2008 to populate the

Custom property <br />sheet fields with attribute tag names and
values read
from a title block.<br /><br />The problem that I
am having is when the
attribute tag names are written to <br />the
Custom property sheet "Name"
fields they are written in lower-case even
<br />though they are defined in
the block as upper-case. I have
tried forcing the <br />attribute tag names
to upper-case which has
no affect.<br /><br />So, I am at a loss. Does
anyone have any
ideas?<br /><br />Below is my work in progress program. I
have
also included a screen capture <br />of the Custom property sheet after

it has been populated.<br /><br />namespace Engineering<br
/>{<br />
public class EngineeringCommands<br
/>    {<br />
[CommandMethod("UPS")]<br
/>        public static void

UpdatePropertySheet()<br
/>        {<br
/>           
Database db =
HostApplicationServices.WorkingDatabase;<br />

DatabaseSummaryInfo dbSummaryInfo;<br />

DatabaseSummaryInfoBuilder dbSummaryInfoBuilder =<br
/>               
new
DatabaseSummaryInfoBuilder();<br /><br
/>            using
(Transaction tr =
<br
/>db.TransactionManager.StartTransaction())<br
/>           
{<br />
BlockTable bt =<br
/>                   
tr.GetObject(db.BlockTableId,
OpenMode.ForRead)<br
/>                       
as BlockTable;<br /><br />
string titleBlock = "22X34";<br
/>               
if (bt.Has(titleBlock))<br

/>               
{<br
/>                   
BlockTableRecord btr =<br />
tr.GetObject(bt[titleBlock],
OpenMode.ForRead)<br />
as BlockTableRecord;<br
/>                   
if (btr != null)<br />
{<br
/>                       
ObjectIdCollection objIdCol =<br />
btr.GetBlockReferenceIds(true,
true);<br
/>                       
if
(objIdCol.Count == 1)<br
/>                       
{<br />
BlockReference br =<br />

tr.GetObject(objIdCol[0], OpenMode.ForRead)<br />
as
BlockReference;<br
/>                           
if (br != null)<br />
{<br
/>                               
foreach (ObjectId attId in <br
/>br.AttributeCollection)<br
/>                               
{<br />
AttributeReference ar =<br />
tr.GetObject(attId,
<br />OpenMode.ForRead)<br />
as AttributeReference;<br
/><br />
dbSummaryInfoBuilder.CustomProperties.Add(ar.Tag, <br
/>ar.TextString);<br

/>                                   
// For AutoCAD 2009, delete the <br
/>statement<br
/>                                   
// above and uncomment
the statement <br />below.<br />

//dbSummaryInfoBuilder.CustomPropertyTable.Add(ar.Tag, <br

/>ar.TextString);<br
/>                               
}<br />
dbSummaryInfo = <br
/>dbSummaryInfoBuilder.ToDatabaseSummaryInfo();<br />

HostApplicationServices.WorkingDatabase.SummaryInfo <br />=

dbSummaryInfo;<br
/>                           
}<br
   }<br
/>                   
}<br
/>               
}<br />
tr.Commit();<br />   }<br /> 
}<br /> }<br />}
Message 4 of 4
Anonymous
in reply to: Anonymous


Thanks Tony!

 

For AutoCAD 2009 I am using >>
dbSummaryInfoBuilder.CustomPropertyTable.Add... which works.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


The issue has been discussed here before and
reported.

 

I haven't checked if it was addressed in
AutoCAD 2009.

 

They didn't do a very good job on that, and there's no known

workaround for it. They unwisely used a StringDictionary
for

storing the data, and it always converts its keys to
lowercase.

 


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 



size=2>
 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost