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

get block subentity

2 REPLIES 2
Reply
Message 1 of 3
a7v1n
784 Views, 2 Replies

get block subentity

hi. how do you get the subentities in a block? i want to compute the intersection of an entity in a block and a line in modelspace. thanks...
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: a7v1n

You use the explode() method to explode the block, and
then transform the resulting entities using the blockref's
BlockTransform property, and then check each exploded
entity for intersection with the model space entity.

That's how you do it.

If you what you are asking for is a detailed code example
showing how to do it, then I wouldn't wait hold my breath,
because it's fairly involved and not many here have the
time to provide that level of tutoring.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

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

wrote in message news:6371615@discussion.autodesk.com...
hi. how do you get the subentities in a block? i want to compute the
intersection of an entity in a block and a line in modelspace. thanks...
Message 3 of 3
JamieVJohnson2
in reply to: Anonymous

Sorry, I couldn't resist.  It is time to exhale and start breathing again.  Patrick Johnson posted some excellent code just for this issue.  I took it and modified it to use nested transactions (a process I find that dramatically speeds up code processing, and makes everything go back in 1 undo command).  Here is that code:

    Public Sub IntersectionPtsForBlocks(ByRef blk As BlockReference, ByRef ent As Entity, ByRef pts As Point3dCollection, ByRef trans As Transaction)
        Using trans2 As Transaction = trans.TransactionManager.StartTransaction
            Dim objs As DBObjectCollection = New DBObjectCollection()
            blk.Explode(objs)
            For Each obj As DBObject In objs
                Dim entBref As Entity = CType(obj, Entity)
                IntersectionPtsForEntities(entBref, ent, pts, trans2)
            Next
            For Each obj In objs
                obj.Dispose()
            Next
            trans2.Commit()
        End Using
    End Sub

    Public Sub IntersectionPtsForEntities(ByRef ent1 As Entity, ByRef ent2 As Entity, ByRef pts As Point3dCollection, ByRef trans As Transaction)
        Try
            If TypeOf ent1 Is Hatch Or TypeOf ent2 Is Hatch Then
                Exit Sub
            Else
                If (TypeOf ent1 Is BlockReference) And (ent1.Visible = True) Then
                    IntersectionPtsForBlocks(ent1, ent2, pts, trans)
                ElseIf (TypeOf ent2 Is BlockReference) And (ent1.Visible = True) Then
                    IntersectionPtsForBlocks(ent2, ent1, pts, trans)
                Else
                    If (ent1.Visible = True) Then
                        Dim intPts As New Point3dCollection
                        ent1.IntersectWith(ent2, Intersect.OnBothOperands, intPts, New IntPtr, New IntPtr)
                        For Each iPoint As Point3d In intPts
                            If Not pts.Contains(iPoint) Then pts.Add(iPoint)
                        Next
                    End If
                End If
            End If
        Catch ex As System.Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

 Hope this helps everybody in need, who may stumble across this post as I did.  Thank you everybody.

 

jvj

jvj

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