Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
ActiveX Selection Sets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
Has anyone tried retrieving an ActiveX selection set in AutoCAD 2013 (AutoCAD Architecture 64bit on Windows 7 is what I am using)?
Using a piece of LISP I got from the ADN developer site, it no longer works and gives this error....
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.
(defun c:erset (/ acApp acDoc selSets ss1)
(vl-load-com)
(setq acApp (vlax-get-acad-object))
(setq acDoc (vla-get-activeDocument acApp))
(setq selSets (vla-get-SelectionSets acDoc))
(setq ss1 (vla-item selSets "TEST1"))
(princ "Number of items in selection set TEST1 = ")
(princ (vla-get-count ss1))
(if (> (vla-get-count ss1) 0)
(progn
(alert "Erasing objects in selection set TEST1")
(vla-erase ss1)
) ;progn
) ;if
(princ)
) ;defun
Same with a similar one I found via google and have been using it for years. Unfortunatley my lisp is very basic so I have little idea if it an be fixed!
(defun c:getSset()
(vl-load-com)
(setq ss-vba (vla-item
(vla-get-selectionsets
(vla-get-activedocument
(vlax-get-acad-object)))
"SSforLisp"));; gets the ActiveX SS
(setq ss-lisp (ssadd));;creates a new ename-based ss
(vlax-for ent ss-vba
(ssadd (vlax-vla-object->ename ent) ss-lisp)
);;add each object's ename to the ename-ss
)
What about creating an AutoLisp selection set from .NET - is it possible, if so I would prefer to do that instead?
The goal is to create some objects in .NET (using activeX or managed code) and then have some way to access these objects via the command line I'm assuming they only way is using an AutoLISP selection set.
Many thanks,
Graham
MiTek Industries
Solved! Go to Solution.
Re: ActiveX Selection Sets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
UPDATE...
I found a sample to transfer a selection set into lisp (using a VB.NET lisp function). Not tested it out yet but it looks promising, I think I need to transfer my activex objects into managed ones and then build a selection set and result buffer?
<LispFunction("MyLispFunction2")> _
Public Function VBNetFunction4(ByVal myLispArgs As ResultBuffer) As ResultBuffer
Dim rbfResult As ResultBuffer
Dim ed As Autodesk.AutoCAD.EditorInput.Editor
ed = Autodesk.AutoCAD.ApplicationServices.Application.D
Dim prmptSelOpts As New PromptSelectionOptions()
Dim prmptSelRes As PromptSelectionResult
prmptSelRes = ed.GetSelection(prmptSelOpts)
If prmptSelRes.Status <> PromptStatus.OK Then
rbfResult = New ResultBuffer(New TypedValue(5019))
Return rbfResult
End If
Dim selSet As SelectionSet
selSet = prmptSelRes.Value
rbfResult = New ResultBuffer( _
New TypedValue(CInt(5007), selSet))
Return rbfResult
End Function
Re: ActiveX Selection Sets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Arrrghh!
Just tested it and it gives the same error message as the other examples!!!
Re: ActiveX Selection Sets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Worked on my end with small changes:
<LispFunction("MyLispFunction2")> _
Public Function VBNetFunction4(ByVal myLispArgs As ResultBuffer) As ResultBuffer
Dim rbfResult As ResultBuffer
Dim ed As Autodesk.AutoCAD.EditorInput.Editor
ed = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument.Editor
Dim prmptSelOpts As New PromptSelectionOptions()
prmptSelOpts.MessageForRemoval = vbLf + "Nothing selected"
prmptSelOpts.MessageForAdding = vbLf + "Select some objects:"
Dim prmptSelRes As PromptSelectionResult
prmptSelRes = ed.GetSelection(prmptSelOpts)
If prmptSelRes.Status <> PromptStatus.OK Then
rbfResult = New ResultBuffer(New TypedValue(5019))
Return rbfResult
End If
Dim selSet As SelectionSet
selSet = prmptSelRes.Value
ed.SetImpliedSelection(selSet)
rbfResult = New ResultBuffer( _
New TypedValue(CInt(5007), ed.SelectImplied.Value))
Return rbfResult
End FunctionIn the command line I've typed
(setq sset (MyLispFunction2))
Another way with using pickfirstselectionset,
see what this function will retain for you:
' (selected objects)
<LispFunction("ListSelected")> _
Public Shared Function ListSelected(resBufIn As ResultBuffer) As ResultBuffer
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim blkId As ObjectId = db.BlockTableId
Dim resBufOut As New ResultBuffer()
If ed.SelectImplied.Value.Count = 0 Then
ed.WriteMessage(vbLf + "Works with previously selected objects only!")
resBufOut.Add(New TypedValue(CInt(LispDataType.Nil)))
Else
Using tr As Transaction = db.TransactionManager.StartOpenCloseTransaction()
Dim bt As BlockTable = TryCast(tr.GetObject(blkId, OpenMode.ForRead), BlockTable)
resBufOut.Add(New TypedValue(CInt(LispDataType.ListBegin)))
Dim sset As SelectionSet = ed.SelectImplied.Value
For Each sobj As SelectedObject In sset
resBufOut.Add(New TypedValue(CInt(LispDataType.ObjectId), sobj.ObjectId))
Next
resBufOut.Add(New TypedValue(CInt(LispDataType.ListEnd)))
End Using
End If
Return resBufOut
End Function
'' usage : (setq entlist (ListSelected))
C6309D9E0751D165D0934D0621DFF27919
Re: ActiveX Selection Sets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Worked like a charm thanks!
Re: ActiveX Selection Sets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Glad to hear that,
Kind regards,
Cheers ![]()
C6309D9E0751D165D0934D0621DFF27919
