Message 1 of 8
Wblock Objects out of drawing in to there own drawings
Not applicable
11-24-2015
07:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Would somone eb able to help me
I am wanting to wblock out each block as i write to my text file but i cant seem to find the correct command to do it
this is my code so far
Try
' Build a filter list so that only
' block references are selected
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim filList As TypedValue() = New TypedValue(0) {New TypedValue(CInt(DxfCode.Start), "INSERT")}
Dim filter As New SelectionFilter(filList)
Dim res As PromptSelectionResult = ed.SelectAll(filter)
' Do nothing if selection is unsuccessful
If res.Status <> PromptStatus.OK Then
Return
End If
Dim selSet As SelectionSet = res.Value
Dim idArray As ObjectId() = selSet.GetObjectIds()
logfile.Write("Block Insersion" & vbTab & "Layer" & vbTab & "Block" & vbTab & "GeometricExtents" & vbTab & "Min" & vbTab & "Max" & vbTab & "Correct Insersion" & vbTab & "L" & vbTab & "D" & vbTab & "H")
Dim objIds As New ObjectIdCollection()
For Each id As ObjectId In idArray
'Dim ent As Entity = TryCast(tr.GetObject(objId, OpenMode.ForRead), Entity)
'Dim br As BlockReference = TryCast(ent, BlockReference)
Dim blkRef As BlockReference = DirectCast(tr.GetObject(id, OpenMode.ForWrite), BlockReference)
Dim btr As BlockTableRecord = DirectCast(tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForWrite), BlockTableRecord)
If Not str.Contains(btr.Name.ToUpper) Then
logfile.Write(Environment.NewLine)
logfile.Write(blkRef.Position.ToString & vbTab)
logfile.Write(blkRef.Layer & vbTab)
logfile.Write(btr.Name & vbTab)
If blkRef.Bounds.HasValue Then
Dim exts As Extents3d = blkRef.GeometricExtents
Dim pt1 = exts.MinPoint
Dim pt2 = exts.MaxPoint
logfile.Write(blkRef.GeometricExtents.ToString & vbTab)
logfile.Write(pt1.ToString & vbTab)
logfile.Write(pt2.ToString & vbTab)
logfile.Write(pt1.X.ToString & "," & pt2.Y.ToString & vbTab)
logfile.Write(pt2.X - pt1.X & vbTab)
logfile.Write(pt2.Y - pt1.Y & vbTab)
logfile.Write(pt2.Z - pt1.Z & vbTab)
If CheckBox1.Checked Then
blkRef.Position = New Point3d(Convert.ToDouble(pt1.X.ToString), Convert.ToDouble(pt2.Y.ToString), Convert.ToDouble(0))
logfile.Write(blkRef.Position.ToString & vbTab)
objIds.Clear()
objIds.Add(id)
THIS IS WHERE I WOULD LIKE TO WBLOCK
objIds.Clear()
End If
Else
logfile.Write("No Extents" & vbTab)
logfile.Write("No Extents" & vbTab)
logfile.Write("No Extents" & vbTab)
logfile.Write("No Extents" & vbTab)
logfile.Write("No Extents" & vbTab)
logfile.Write("No Extents" & vbTab)
logfile.Write("No Extents" & vbTab)
End If
str.Add(btr.Name.ToUpper)
End If
btr.Dispose()
Next
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(("Exception: " + ex.Message))
logfile.Write(Environment.NewLine)
Finally
tr.Dispose()
End TryI was trying to do it with the objIds but i have had no luck