Code Red > .NET
AutoCAD DevBlog
TT:
--- Quote from: gile on July 13, 2012, 12:24:12 pm ---.... (search for GetObjects<T> in this forum for instance)....
--- End quote ---
Hmmmm.
I just did that. Searching for GetObjects<T> produces no results.
Searching for 'GetObjects' (without the "<T>"), returns only your post containing the above quote. :s
Keith™:
--- Quote from: TheMaster on July 13, 2012, 02:31:43 pm ---
--- Quote from: gile on July 13, 2012, 12:24:12 pm ---.... (search for GetObjects<T> in this forum for instance)....
--- End quote ---
Hmmmm.
I just did that. Searching for GetObjects<T> produces no results.
Searching for 'GetObjects' (without the "<T>"), returns only your post containing the above quote. :s
--- End quote ---
There are two things at work here ... first the forum software apparently doesn't work with come characters or it treats them as some kind of code i.e. GetObjects<T> will not return anything. Removing the <T> will produce results ... which brings me to the second item. Searching from within any board or child-board only returns hits from those boards and its children. To search the entire swamp forum, you have to search from the main page.
Searching from the main page using GetObjects returns about 20 hits.
TT:
--- Quote from: Keith™ on July 13, 2012, 03:47:18 pm ---
Searching from within any board or child-board only returns hits from those boards and its children. To search the entire swamp forum, you have to search from the main page.
Searching from the main page using GetObjects returns about 20 hits.
--- End quote ---
Thanks.
The second attempt was made at the result page for the first attempt, so I would have expected it to have the same scope, but guess not.
gile:
.NET isn't necessary as verbose as shown in AutoCAD DevBlog...
--- Quote ---There is no .NET API for it, but a COM API that can be used from .NET with AcSelect mode as acSelectionSetCrossingPolygon. The following sample function demonstrate it, and after an example of how use it. This code uses Late Binding, so you can use on your .NET code without need to reference Interop assemblies.
--- Code - vb.net: ---Public Shared Function selectCrossing(ByVal pline As Polyline, _ ByVal entitiesNames As String) _ As ObjectIdCollection 'This method was designed using COM/ActiveX API, but all types 'were replaced with Object, which means we're using Late Binding. 'Therefore no Interop references are needed 'AcadApplication Dim acadApp As Object = Application.AcadApplication 'AcadDocument Dim acadDoc As Object = acadApp.ActiveDocument Dim ssetObj As Object Dim pointsArray(0) As Double Dim grpCode(0) As Integer Dim grpValue(0) As Object Dim mode As Integer 'this selection only works with entities visible on the screen, 'so we need to extend to make sure everything is visible 'acadApp.ZoomExtends() 'acadApp.Update() ReDim pointsArray(pline.NumberOfVertices * 3 - 1) For i As Integer = 0 To pline.NumberOfVertices - 1 Dim vertice As Point3d = pline.GetPoint3dAt(i) pointsArray(i * 3 + 0) = vertice.X pointsArray(i * 3 + 1) = vertice.Y pointsArray(i * 3 + 2) = vertice.Z Next 'will store the entities inside the region Dim objIdColl As New ObjectIdCollection ssetObj = acadDoc.SelectionSets.Add("TEMPSELSET1") ssetObj.Clear() Dim gpCode As Int16() ReDim gpCode(1) gpCode(0) = 0 gpCode(1) = 10 Dim dataValue As Object() ReDim dataValue(0) dataValue(0) = entitiesNames Dim groupCode As Object, dataCode As Object groupCode = gpCode dataCode = dataValue 'these modes are definied under 'Autodesk.AutoCAD.Interop.Common.AcSelect 'but again we're not using explicit Interop references mode = 7 'AcSelect.acSelectionSetCrossingPolygon ssetObj.SelectByPolygon(mode, pointsArray, groupCode, dataCode) ' if one or more point entities in the selection area If ssetObj.count >= 1 Then For Each ent In ssetObj objIdColl.Add(New ObjectId(New IntPtr(CLng(ent.ObjectID)))) Next ent End If ssetObj.Delete() 'delete the temp selection set 'acadApp.ZoomPrevious() 'restore the zoom Return objIdCollEnd Function
--- End quote ---
F# equivalent (using the .NET API which does exist)
--- Code - F#: ---let selectCrossing (pline: Polyline) (entityNames: string) = let ed = Application.DocumentManager.MdiActiveDocument.Editor let pointsArray = [| for i in 0 .. pline.NumberOfVertices - 1 -> pline.GetPoint3dAt(i) |] use view = ed.GetCurrentView() zoomExtents() let psr = ed.SelectCrossingPolygon( new Point3dCollection(pointsArray), new SelectionFilter([| new TypedValue(0, entityNames) |])) ed.SetCurrentView(view) match psr.Status with | PromptStatus.OK -> new ObjectIdCollection(psr.Value.GetObjectIds()) | _ -> new ObjectIdCollection()
Kerry:
Hmmm ..
I wonder why he used COM instead of .NET for the solution ??
and ...
'acadApp.ZoomExtends()
should be
'acadApp.ZoomExtents()
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version