DURCH DIE BRUST INS AUGE DURCHS KNIE GESCHOSSEN
Selektionen an "CURRENT" uebertragen geht nur wenn die elemente einmal durch die selectionset.select funktion
wie auch immer gelaufen sind. Kann man gut mit selectonscreen testen aber das wollte ich ja gerade nicht
Elemente einfach nur ins "CURRENT" reinzukopieren funktioniert nicht.
Mit der xdata loesung bin ich noch nicht ganz zufrieden aber sie tut das was sie soll.
der lisp teil kann sicherlich auch durch vba ersetzt werden.
Nur ich hab es irgendwie nicht hinbekommen Gruppen nach Namen zu filtern oder nach XDATA werten.
Anyhow, es tut ersteinmal und nun kann ich mir z.B ein besseres Quickselect bauen,
eine gescheite Gruppenselektion nachruesten, bestimmte Biegeformen aktivieren usw.
LG aus finnland
Sub selection_previous_delete()
'purpose is to clear the last setelctionset
'otherwise the last used might be activated
Dim xDataType(1) As Integer
Dim xDataValue(1) As Variant
Dim P As AcadPoint
Dim location(0 To 2) As Double
'create fake pointelement
location(0) = 0#: location(1) = 0#: location(2) = 0#
Set P = ThisDrawing.modelspace.AddPoint(location)
XAPPNAME = "SEL"
xDataType(0) = 1001
xDataValue(0) = XAPPNAME
xDataType(1) = 1000
xDataValue(1) = "1"
'set xdata to fakeelement
P.SetXData xDataType, xDataValue
'first wait until acad is bored
Set State = GetAcadState
Do Until State.IsQuiescent
DoEvents
Set State = GetAcadState
Loop
'activate fakepointelement
CMD1 = Chr(27) & Chr(27) & "(setq #filter (ssget " & Chr(34) & "x" & Chr(34) & "'((-3 (" & Chr(34) & XAPPNAME & Chr(34) & ")))))" & vbLf
CMD2 = (Chr(27) & Chr(27) & "_PSELECT" & vbLf & "_P" & vbLf & vbLf)
ThisDrawing.SEndCommand CMD1 & CMD2
'delete fake
Application.UPDATE
P.Delete
End Sub
Sub selection_set_activate(ByVal selectionset As AcadSelectionSet)
'to set the entitys active you has first usually to use the
'selectionset.select function
'otherwise the selectionset can not be activated
'ensure nothing is selectef
Application.UPDATE
If SLOPEFORM.CURRENTGROUP.Value = "" Then Exit Sub
Dim GROUP As AcadGroup
Dim entity As AcadEntity
Dim handle As Long
Dim xDataType() As Integer
Dim xDataValue() As Variant
ReDim xDataType(1)
ReDim xDataValue(1)
Dim XAPPNAME As String
'kill the last selection first
selection_previous_delete
'mark all entitys inside selectionset with a temporary xdata mark
XAPPNAME = "SEL"
xDataType(0) = 1001
xDataValue(0) = XAPPNAME
xDataType(1) = 1000
xDataValue(1) = "1"
For Each entity In selectionset
entity.SetXData xDataType, xDataValue
Next
'ensure acad is bored
Set State = GetAcadState
Do Until State.IsQuiescent
DoEvents
Set State = GetAcadState
Loop
'use a lisp function to select the desired xdata marked elements, cmd1 should be also possible with plain VBA just got the filter not created
CMD1 = Chr(27) & Chr(27) & "(setq #filter (ssget " & Chr(34) & "x" & Chr(34) & "'((-3 (" & Chr(34) & XAPPNAME & Chr(34) & ")))))" & vbLf
'activate last selectionset from cmd1
CMD2 = (Chr(27) & Chr(27) & "_PSELECT" & vbLf & "_P" & vbLf & vbLf)
ThisDrawing.SEndCommand CMD1 & CMD2
'remove temporary xdata
ReDim Preserve xDataType(0)
ReDim Preserve xDataValue(0)
For Each entity In selectionset
entity.SetXData xDataType, xDataValue
Next
End Sub
------------------
Wer es nicht versucht, hat schon verlorn
Und bei 3 Typos gibts den vierten gratis !
[Diese Nachricht wurde von rexxitall am 11. Aug. 2013 editiert.]
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP