Search the Community
Showing results for tags 'selectionset'.
Found 4 results
How to utilize built-in Rotate command with SelectionSet?
Alex_AMF posted a topic in .NET, ObjectARX & VBAHello, Our users must be able to rotate a bunch of lines, circles, blocks etc (which result in looking like a conveyor). I am trying to pass a SelectionSet using the built-in rotate command of AutoCAD. I got a lot of help on the AutoDesk forums: http://forums.autodesk.com/t5/net/how-to-pass-objectidcollection-into-built-in-rotate-command/m-p/5429159#M42620 I seem to be in a stalemate right now. I don't have AutoCAD 2015 so I use a RunCommand wrapper to enable me to use the editor.Command(). Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports System.Linq.Expressions Imports System.Reflection Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.EditorInput Module EditorInputExtensionMethods <System.Runtime.CompilerServices.Extension()> _ Public Function Command(editor As Editor, ParamArray args As Object()) As PromptStatus If editor Is Nothing Then Throw New ArgumentNullException("editor") End If Return runCommand(editor, args) End Function Dim runCommand As Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand() Private Function GenerateRunCommand() As Func(Of Editor, Object(), PromptStatus) Dim method As MethodInfo = GetType(Editor).GetMethod("RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.[Public]) Dim instance As ParameterExpression = Expression.Parameter(GetType(Editor), "editor") Dim args As ParameterExpression = Expression.Parameter(GetType(Object()), "args") Return Expression.Lambda(Of Func(Of Editor, Object(), PromptStatus))(Expression.Call(instance, method, args), instance, args).Compile() End Function End Module I then populate my SelectionSet using an object ID collection that was built. Here is my code that I use to try and use the already built-in rotate command that AutoCAD has to offer: <CommandMethod("My-Rotate")> _ Public Sub MyRotate() 'Get the current document and database Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database Dim acObj As Object Dim entRes As PromptEntityResult Dim entOpts As PromptEntityOptions Dim rb As ResultBuffer Dim FoundHunter As Boolean Dim acBlkTbl As BlockTable Dim acBlkTblRec As BlockTableRecord Dim pickedPolyline As Polyline = Nothing Dim SelSet As SelectionSet Dim Lst_ObjId As New List(Of ObjectId) 'Prompt user to select the conveyor he wants to rotate Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView() entOpts = New PromptEntityOptions(vbLf & "Choose the object you wish to rotate") entRes = acDoc.Editor.GetEntity(entOpts) If (entRes.Status = PromptStatus.OK) Then 'Start a transaction Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() acObj = entRes.ObjectId.GetObject(OpenMode.ForRead) 'Make sure the selected object was a polyline If Not TypeOf acObj Is Polyline Then MsgBox("You must choose a line or polyline") : Exit Sub rb = New ResultBuffer rb = entRes.ObjectId.GetObject(OpenMode.ForRead).XData() 'Sets the correct Project Conveyor ProjectConveyor.SetByDataTable(GetPKFromResultBuffer(rb), Project.PK_Project) 'Open the Block table for read acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) 'Open the Block table record Model space for write acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite) 'Go through the Block Table Record and build the collection ID For Each acObjId As ObjectId In acBlkTblRec rb = New ResultBuffer rb = acObjId.GetObject(OpenMode.ForRead).XData() FoundHunter = False If Not rb Is Nothing Then For Each tv As TypedValue In rb If tv.TypeCode = DxfCode.ExtendedDataRegAppName Then If tv.Value = "MY_PROGRAM_NAME" Then FoundHunter = True End If If FoundHunter And tv.TypeCode = DxfCode.ExtendedDataInteger32 Then If tv.Value = ProjectConveyor.PK_ProjectConveyor Then Lst_ObjId.Add(acObjId) 'Sets up all object IDs correctly here Exit For End If End If Next rb.Dispose() End If Next 'Create a selection set from object IDs SelSet = SelectionSet.FromObjectIds(Lst_ObjId.ToArray) 'Use AUTOCAD's Rotate function knowing we have all selections in selection set acDoc.Editor.Command("_.rotate", SelSet, "") 'Save the new objects to the database ProjectConveyor.Update() acTrans.Commit() End Using End If End Sub My issue is, whenever I get to the acDoc.Editor.Command() portion, it does not prompt the user to rotate anything. It returns Error(-5001) ... Any ideas?
vbarun cancels selection?
tanarri posted a topic in .NET, ObjectARX & VBAHi, I am writing code on modifying items in pickfirstselectionset. Everything goes well in VBA editor. But after I attached macro to a toolbar button, the selection is cancelled when clicking the button and then no changes to the previous selected objects. I used vbarun in command line, it's the same. anyone knows how to fix it? Thx in advance. I'm familiar with VBA, but absolutely new with AutoCAD. I kind of sense it's a rookie questioin but I can't find a solution on the web.
VBA Selection Set Issue
meyerforhire posted a topic in .NET, ObjectARX & VBAHey gang! Quick question (hopefully).... Would there be any reason why several block references with (Locked and Constant) attributes do not get added to a Selection Set created using the .Select acSelectionSetWindow method? It's picking up all of the other items including block references, text, and even a block reference with an attribute that is not locked nor constant. The problem blocks are right in the middle of the window surrounded by everything else that is getting added. I am not attempting to use a filter. I am using AutoCAD 2012.
Create selectionset with active selection (in VBA)
ronanry posted a topic in .NET, ObjectARX & VBAHi everyone, If you read these line, i hope you're little familar with selectionset in vba I made some search in google and on a lot of forum with the text i put in the title but everything i can find is the "prompt for an object to select" Never ever i was able to launch any command with ACTIVE object selected What i try to do is to launch a macro (when clicking on a button, this part is good) and this macro should use current object to find X and Y (this part is good... but only after selecting a new object) Thanks you for reading and for giving any path to seek on ...