abraxus Posted October 1, 2013 Share Posted October 1, 2013 I have the following code which is simple, and works just fine when a polyline is selected, but when a block reference is selected, the explode method returns no objects at all The documentation says that Explode should work on blocks, so I do not understand what I am overlooking here I have attached a dwg with the block i'm trying to process, and it also has a random polyline - see what happens when you select the block - the block DOES actually explode, but still no return objects Sub test() Dim f1 As AcadEntity Dim entNewBlock As AcadEntity Dim basePnt As Variant Dim entExplodedItems As Variant ThisDrawing.Utility.GetEntity f1, basePnt, "Select an object" ' make a copy of the block Set entNewBlock = f1.Copy ' explode the block - returns an array of objects that were created from the block ' this should return 12 line objects entExplodedItems = entNewBlock.Explode If UBound(entExplodedItems) = -1 Then MsgBox "Explode returned no objects" Exit Sub Else MsgBox "Explode returned " & UBound(entExplodedItems) & " items" End If End Sub explode-test.dwg Quote Link to comment Share on other sites More sharing options...
SEANT Posted October 1, 2013 Share Posted October 1, 2013 Apparently Autodesk has not fully implemented exploding Non Uniformly Scaled blocks in AutoCAD via VBA. I notice that the block has lines with Thickness: Is this still related to detecting collisions? Quote Link to comment Share on other sites More sharing options...
abraxus Posted October 2, 2013 Author Share Posted October 2, 2013 I see... i didnt test it with a non-uniformly-scaled block, but that might explain it i noticed some other things about the block too (i do not have control over the block definition, it has to stay the way that it is) but instead of "4 simple lines" there are 4 lines on top of one another for each of the four lines... ugh... whoever setup that block didnt pay very close attention to detail i did, however find an alternate way of doing what i wanted to do, but it only works because the block definition SHOULD be 4 simple lines all at 90 degrees since it's just a basic rectangle, defined by a rotation value and the X and Y scale factors, i decided to just start at the insertion point, and draw the polyline based on polar coordinates and the XY scale factors, then use that polyline instead of the block definition to pass to the IntersectWith method (yes, this is related to the collision topic i also created) one of the lines having thickness is very important in other aspects that arent related to my project, and that cannot be changed either so in short, i guess consider this topic closed, since (as you say) there is no solution other than just recreating it manually using the other given information for anyone curious, this is my solution which worked in my case only Public Function GetPolyFixture(f1 As AcadBlockReference) As AcadPolyline Dim entPolyline As AcadPolyline Dim pt2 As Variant Dim pt3 As Variant Dim pt4 As Variant Dim dLineArray(11) As Double Const Radians90 = 1.570796325 ' get the corner points pt2 = ThisDrawing.Utility.PolarPoint(f1.InsertionPoint, f1.Rotation, Abs(f1.XScaleFactor)) pt3 = ThisDrawing.Utility.PolarPoint(pt2, f1.Rotation - Radians90, Abs(f1.YScaleFactor)) pt4 = ThisDrawing.Utility.PolarPoint(pt3, f1.Rotation - (2 * Radians90), Abs(f1.XScaleFactor)) ' put them into an array dLineArray(0) = f1.InsertionPoint(0) dLineArray(1) = f1.InsertionPoint(1) dLineArray(2) = f1.InsertionPoint(2) dLineArray(3) = pt2(0) dLineArray(4) = pt2(1) dLineArray(5) = pt2(2) dLineArray(6) = pt3(0) dLineArray(7) = pt3(1) dLineArray( = pt3(2) dLineArray(9) = pt4(0) dLineArray(10) = pt4(1) dLineArray(11) = pt4(2) ' draw a polyline that matches fixture Set entPolyline = ThisDrawing.ModelSpace.AddPolyline(dLineArray) entPolyline.Closed = True entPolyline.Layer = "0" ' return polyline object Set GetPolyFixture = entPolyline End Function Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.