Retrieve info from Block inserted in dwg inserted in another one (XRef

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello , coninuing from my last post : https://forums.autodesk.com/t5/net/extract-attribut-info-from-a-block-in-a-xref/m-p/6829239#M51769
i need to extract information :
- Position of the block in xref (but position on WCS on the current dwg).
- Scale X or Y or Z of the block in xref (but position on WCS on the current dwg)
i have this code for getting the entity :
Dim opt As PromptNestedEntityOptions = New PromptNestedEntityOptions(vbCrLf & cTexteInfo) opt.AllowNone = False Dim BlocRef As BlockReference = Nothing retry: Dim prompSelRes As PromptNestedEntityResult Do While (True) prompSelRes = Ed.GetNestedEntity(opt) If (prompSelRes.Status = PromptStatus.Cancel) Then Return "annulation manuelle" Dim entity = tr.GetObject(prompSelRes.ObjectId, OpenMode.ForRead) If TypeOf (entity) Is AttributeReference Then 'aquisition du bloc réf BlocRef = tr.GetObject(entity.OwnerId, OpenMode.ForRead) Ed.WriteMessage(vbCrLf & "Nom du bloc (Xref[att]) : " & BlocRef.Name) Exit Do End If Dim containers = prompSelRes.GetContainers() If (containers.Length > 0) Then BlocRef = tr.GetObject(containers(0), OpenMode.ForRead) 'Ed.WriteMessage(vbCrLf & "Nom du bloc (Xref) : " & BlocRef.Name) Exit Do End If Ed.WriteMessage(vbCrLf & "L'objet sélectionné n'est pas un bloc.") Loop
with this i have the BlockRef and i can retrieve the BlockDef (see the link above).
but now , how i can check the position in the current drawing ?
i trying : (from here)
Dim brMat As Matrix3d = Matrix3d.Identity
brMat = brMat.PreMultiplyBy(BlocRef.BlockTransform)
brMat = brMat.PreMultiplyBy(brMat.Inverse())
brMat = brMat.PostMultiplyBy(brMat)
Dim newEnt As Entity = BlocRef.Clone()
newEnt.TransformBy(prompSelRes.Transform.PostMultiplyBy(Matrix3d.Displacement(New Vector3d(0.1, 0.1, 0))))
but this not working and crash if the block have a scale of 1/0.9/0.9 for exemple ...
The .position from the new block is not good too.
can you help me ?
(I need this for create a arc with point1/point is the location of 2 block in Xref.