Dill Posted July 23, 2010 Share Posted July 23, 2010 i want to explode blockrefs to have a closer look at the objects inside. what i first tried is to retrieve the coordinates of a polyline inside a blockref. but i get a "Type Mismatch" error when i set a polyline-ref to an object of the explode-array. (though it has ObjectName == AcDbPolyline). If varEx(i).ObjectName = "AcDbPolyline" Then Set pl = varEx(i) 'ERROR: Type mismatch '(...) End If i need an AcadPolyline object to access the Coordinates property. How is this done? Im not used to VB but i find its object model rather confusing... here is the full code: Public Sub Test() Dim bref As AcadBlockReference Dim ent As AcadEntity Dim exp As Variant Dim pl As AcadPolyline For Each ent In ThisDrawing.ModelSpace If ent.ObjectName = "AcDbBlockReference" Then Set bref = ent Debug.Print "exploding", bref.Name Dim i As Double varEx = bref.Explode For i = 0 To UBound(varEx) Debug.Print varEx(i).ObjectName If varEx(i).ObjectName = "AcDbPolyline" Then Set pl = varEx(i) 'ERROR: Type mismatch '(...) End If Next End If Next End Sub thank you! Quote Link to comment Share on other sites More sharing options...
10west Posted July 26, 2010 Share Posted July 26, 2010 SSET2.SelectOnScreen For Each ent In SSET2 If (TypeOf ent Is AutoCAD.AcadLWPolyline) Then Set lwpl = ent vtxs = lwpl.Coordinates For idx = LBound(vtxs) To UBound(vtxs) Step 2 List1(0).AddItem vtxs(idx) List1(1).AddItem vtxs(idx + 1) Next idx End If Next ent Maybe experiment with setting to an object, then set the obj to the varEx return Quote Link to comment Share on other sites More sharing options...
Dill Posted July 26, 2010 Author Share Posted July 26, 2010 (edited) did i understand you correct: Dim o As AcadObject (...) Set o = varEx(i) Set pl = o same error. would it help to try .net or will i be using the same lib? thanks for your help. EDIT: python does it. heres an example with a .dwg containing nothing but a bref consiting of a 3 vertices polyline. doesnt work with older acad version, tested here on acad 11. >>> import win32com.client >>> acad = win32com.client.Dispatch("AutoCAD.Application") >>> doc = acad.ActiveDocument >>> ms = doc.ModelSpace >>> >>> for item in ms: ... print item.ObjectName ... AcDbBlockReference >>> bref = ms[0] >>> exp = bref.Explode() >>> exp (<COMObject Explode>,) >>> e=exp[0] >>> e.ObjectName u'AcDbPolyline' >>> e.Coordinates (1000.0, 500.0, 1000.0, 600.0, 1100.0, 600.0, 1100.0, 500.0, 1000.0, 500.0) Edited July 26, 2010 by Dill Quote Link to comment Share on other sites More sharing options...
10west Posted July 29, 2010 Share Posted July 29, 2010 Make sure you try all the possible polylines if LWpoly is still included. 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.