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

Dynamic block question

16 REPLIES 16
Reply
Message 1 of 17
gagangajabaharia
1644 Views, 16 Replies

Dynamic block question

I have a BlockTableRecord that represents a dynamic block. This dynamic block has several visibility states. How can I access these individual visibility states from this BlockTableRecord? I see that there is GetAnonymousBlockIds() method - is this the one to be looked into for this purpose?

Thanks, Gagan
16 REPLIES 16
Message 2 of 17
Anonymous
in reply to: gagangajabaharia

How does the user control the visiblity state?

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6345831@discussion.autodesk.com...
I have a BlockTableRecord that represents a dynamic block. This dynamic block
has several visibility states. How can I access these individual visibility
states from this BlockTableRecord? I see that there is GetAnonymousBlockIds()
method - is this the one to be looked into for this purpose?

Thanks, Gagan
Message 3 of 17
Anonymous
in reply to: gagangajabaharia

On 2/28/2010 1:44 PM, gagangajabaharia wrote:

> This dynamic block has several visibility states. How can I access
> these individual visibility states from this BlockTableRecord?

Take a look at this example (watch for wordwrap on the link).

http://through-the-interface.typepad.com/through_the_interface/2009/03/accessing-the-properties-of-a-dynamic-autocad-block-using-net.html

Terry
Message 4 of 17
Anonymous
in reply to: gagangajabaharia

On 2/28/2010 3:46 PM, Terry W. Dotson wrote:

> Take a look at this example ...

It appears they are creating an instance of a BlockReference in memory
and walking through it's DynamicBlockReferencePropertyCollection without
actually appending the object to the database.

Terry
Message 5 of 17
sgrya1
in reply to: gagangajabaharia

Here is a vb version but taken from this post.

http://discussion.autodesk.com/forums/thread.jspa?messageID=5156444?

_
Public Sub DynamicBlockProperties()
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager
Dim trans As Transaction = tm.StartTransaction
Dim pso As PromptSelectionOptions = New PromptSelectionOptions("Select Block ")
pso.SingleOnly = True
pso.SelectEverythingInAperture = True
Dim psr As PromptSelectionResult = ed.GetSelection(pso)
Dim br As BlockReference = trans.GetObject(psr.Value(0).ObjectId, OpenMode.ForRead, False, True)
If (br.IsDynamicBlock) Then
Dim dynBrProColl As DynamicBlockReferencePropertyCollection
dynBrProColl = br.DynamicBlockReferencePropertyCollection
Dim dynBrPro As DynamicBlockReferenceProperty
For Each dynBrPro In dynBrProColl
ed.WriteMessage(dynBrPro.PropertyName + " ")
ed.WriteMessage(dynBrPro.Value.ToString())
ed.WriteMessage("\n")
Next
Else
ed.WriteMessage("The block is not dynamic")
End If
End Sub Edited by: sgrya1 on Mar 1, 2010 12:39 AM
Message 6 of 17
Anonymous
in reply to: gagangajabaharia

Both yourself and Terry do not understand the question.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6345899@discussion.autodesk.com...
Here is a vb version but taken from this post.

...
Message 7 of 17
Anonymous
in reply to: gagangajabaharia

You need to clarify your question, as it's already
left a few confused.

For example, do you want to know what entities in
the block are visible for a given visiblity state?

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6345831@discussion.autodesk.com...
I have a BlockTableRecord that represents a dynamic block. This dynamic block
has several visibility states. How can I access these individual visibility
states from this BlockTableRecord? I see that there is GetAnonymousBlockIds()
method - is this the one to be looked into for this purpose?

Thanks, Gagan Edited by: Discussion_Admin on Mar 1, 2010 5:49 PM
Message 8 of 17

Sorry for the late response - I had forgotten to mark "Watch this thread".

Yes Tony, that is exactly what I am trying to get at : what entities are visible for a given visibility state of a dynamic block.

Thank you, Gagan
Message 9 of 17

Thank you - this gives me the properties for the dynamic block. I need to know the entities visible for a given visibility state of the blockreference. Sorry about the confusion.

Thanks, Gagan
Message 10 of 17

User controls the visibility state using the standard AutoCAD UI - select the dynamic block (i.e. insert) and then click on the little triangle to display the available visibility states and click on one of them to choose. I want to be able to get at the entities that are displayed when user chooses a particular visibility state.

Thanks you, Gagan



> {quote:title=Guest wrote:}{quote}
> How does the user control the visiblity state?
>
> --
> http://www.caddzone.com
>
> AcadXTabs: MDI Document Tabs for AutoCAD
> Supporting AutoCAD 2000 through 2010
>
> http://www.acadxtabs.com
>
> Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
>
> wrote in message news:6345831@discussion.autodesk.com...
> I have a BlockTableRecord that represents a dynamic block. This dynamic block
> has several visibility states. How can I access these individual visibility
> states from this BlockTableRecord? I see that there is GetAnonymousBlockIds()
> method - is this the one to be looked into for this purpose?
>
> Thanks, Gagan
Message 11 of 17
Anonymous
in reply to: gagangajabaharia

What you need isn't available via any documented API, I'm afraid.

You can get it, but it requires the use of acdbEntGet() (which you
have to P/Invoke from managed code).

Attached is a screen grab showing the DXF fields for the object
that stores the visibility states for a dynamic block. That object
is buried in the dynamic block def's extension dictionary, and
is an instance of an "AcDbBlockVisibilityParameter" (that's the
native ObjectARX class and the runtime class name, it's not the
managed wrapper type).

The right side shows the DXF fields for that object, and you can
see the DXF fields for a single visiblity state. The 303 string is the
name of the visiblity state. The next item (code 94) is an integer
that holds the number of ObjectIds that immediately follow, which
are the ids of the block entities that are explicitly visible in that state.

The DXF data for the AcDbBlockVisibilityParameter contains this
same set of fields for each visibility state. Since there can only be
a single visibility state for each dynamic block, you can just seek
the DXF data of the owner object to locate it's ObjectId, and then
call acdbEntGet() on that, to get the visibility state data.

So, the steps are:

1. Get the BlockTableRecord for the dynamic block definition.

2. Get the extension dictionary for the BlockTableRecord.

3. Get ObjectId of the "ACAD_ENHANCEDBLOCK" entry in
the extension dictionary.

4. call acdbEntGet() on ObjectId obtained in step 3, which
returns a ResultBuffer containing TypedValues.

5. Iterate over the TypedValues looking for an item whose group
code is 360, and get the ObjectId stored in the TypedValue's
Value property, then get value of the 'Name' property of the
ObjectId's ObjectClass property, and see if it equals the string
"AcDbBlockVisibilityParameter".

6. Once you've found the AcDbBlockVisibilityParameter object's
ObjectId, call acdbEntGet() on it, and data like that shown on
the right side of the screen grab is returned in a ResultBuffer.

7. Iterate over the TypedValues in the ResultBuffer returned by
acdbEntGet(), looking for an item whose group code is 303,
and whose string value equals the name of the visibility group.

8. Get the next element from the ResultBuffer, which is a 94
group code whose value is the number of ObjectIds that
follow, and then read that many subsequent items having a
group code of 331, and collect the ObjectIds in each into a
list, and you then have the ObjectIds of the block entities
that are explicitly visible in the visiblity state.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6346232@discussion.autodesk.com...
Sorry for the late response - I had forgotten to mark "Watch this thread".

Yes Tony, that is exactly what I am trying to get at : what entities are visible
for a given visibility state of a dynamic block.

Thank you, Gagan
Message 12 of 17

Thanks, Tony for the detailed explanation. If this is the only way, I will have to bite the bullet and go that way - I am sure I will questions along the way.

Thanks, Gagan

> {quote:title=Guest wrote:}{quote}
> What you need isn't available via any documented API, I'm afraid.
>
> You can get it, but it requires the use of acdbEntGet() (which you
> have to P/Invoke from managed code).
>
> Attached is a screen grab showing the DXF fields for the object
> that stores the visibility states for a dynamic block. That object
> is buried in the dynamic block def's extension dictionary, and
> is an instance of an "AcDbBlockVisibilityParameter" (that's the
> native ObjectARX class and the runtime class name, it's not the
> managed wrapper type).
>
Message 13 of 17
Anonymous
in reply to: gagangajabaharia


If you need something quick and dirty and don't
have the time or desire to put forth that type of effort, simply copy the a
dynamic block instance using that visibility state and explode it, examine the
resulting geometry, then delete it once you've examined it.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks,
Tony for the detailed explanation. If this is the only way, I will have to
bite the bullet and go that way - I am sure I will questions along the way.
Thanks, Gagan > {quote:title=Guest wrote:}{quote} > What you need isn't
available via any documented API, I'm afraid. > > You can get it, but it
requires the use of acdbEntGet() (which you > have to P/Invoke from managed
code). > > Attached is a screen grab showing the DXF fields for the
object > that stores the visibility states for a dynamic block. That object
> is buried in the dynamic block def's extension dictionary, and > is an
instance of an "AcDbBlockVisibilityParameter" (that's the > native
ObjectARX class and the runtime class name, it's not the > managed wrapper
type). >
Message 14 of 17
Anonymous
in reply to: gagangajabaharia

{quote}

If you need something quick and dirty and don't have the time or desire to put
forth that type of effort, simply copy the a dynamic block instance using that
visibility state and explode it, examine the resulting geometry, then delete it
once you've examined it.

{quote}

I don't think that would work, because there's nothing in the entities produced
by exploding the dynamic block that tells what entities are associated with a
given visibility state. IOW, not all visible entities in a dynamic block need to
be associated with a visibility state.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

"Darren J. Young" wrote in message
news:6354065@discussion.autodesk.com...
If you need something quick and dirty and don't have the time or desire to put
forth that type of effort, simply copy the a dynamic block instance using that
visibility state and explode it, examine the resulting geometry, then delete it
once you've examined it.
wrote in message news:6346482@discussion.autodesk.com...
Thanks, Tony for the detailed explanation. If this is the only way, I will
have to bite the bullet and go that way - I am sure I will questions along the
way. Thanks, Gagan > {quote:title=Guest wrote:}{quote} > What you need isn't
available via any documented API, I'm afraid. > > You can get it, but it
requires the use of acdbEntGet() (which you > have to P/Invoke from managed
code). > > Attached is a screen grab showing the DXF fields for the object >
that stores the visibility states for a dynamic block. That object > is buried
in the dynamic block def's extension dictionary, and > is an instance of an
"AcDbBlockVisibilityParameter" (that's the > native ObjectARX class and the
runtime class name, it's not the > managed wrapper type). >
Message 15 of 17
Anonymous
in reply to: gagangajabaharia

{quote}
I don't think that would work, because there's nothing in the entities
produced
by exploding the dynamic block that tells what entities are associated with
a
given visibility state. IOW, not all visible entities in a dynamic block
need to
be associated with a visibility state.
{quote}

Good point Tony and an important nuance to the question..Are they looking
for the entities visible when a given visibility state or entities that are
actually associated to particular visibility state as visible.
Message 16 of 17
Anonymous
in reply to: gagangajabaharia

The way I read it, the OP wanted to know what entities
are associated with a given visibility state.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

"Darren J. Young" wrote in message
news:6356789@discussion.autodesk.com...
{quote}
I don't think that would work, because there's nothing in the entities
produced
by exploding the dynamic block that tells what entities are associated with
a
given visibility state. IOW, not all visible entities in a dynamic block
need to
be associated with a visibility state.
{quote}

Good point Tony and an important nuance to the question..Are they looking
for the entities visible when a given visibility state or entities that are
actually associated to particular visibility state as visible.
Message 17 of 17
jcheard
in reply to: Anonymous

Tony,

 

I'm trying to do the same thing but Step 4 Returns nothing.  however, I can clearly see using ArxDbg that there should be a Result Buffer returned.  What could cause this not to work? 

 

BTW -- I'm using AutoCAD 2009 - Service Pack 4

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