Does anyone have an example piece of code that adds preselected objects to a selection set or prompts the user and passes the result to a selection set
Thanks in advance
#2
Here's what I've got so far. The following will prompt for points from the user but doesn't show a select box between picks (anyone have an idea how to make it display that) I still haven't figured out how to pass preselected entities to the macro. I'm thinking that I have to find the name of the default selection set created when a user prepicks entities.
Private Sub CommandButton4_Click()
' dimension the variables
Dim objSS As SelectionSet
Dim DxfFileName As String
Dim pnt1 As New DWGeditor.Point
Dim pnt2 As New DWGeditor.Point
'On Error Resume Next
DWGeditor.ActiveDocument.Activate
' add the selection set name to the drawing database
Set objSS = DWGeditor.ActiveDocument.SelectionSets.Add("SetName")
' Hide Userform
Me.Hide
' set a pointer to the point object by using the GetPoint method in VBA
Set pnt1 = ThisWorkspace.ActiveDocument.Utility.GetPoint(, "upper left of select box")
' set a pointer to the point object by using the GetPoint method in VBA
Set pnt2 = ThisWorkspace.ActiveDocument.Utility.GetPoint(, "lower right of select box")
' populate the selection set with the drawing entity objects
objSS.Select vicSelectionSetInsideWindow, pnt1, pnt2
' highlight all the entities in the selection set
objSS.Highlight True
' Have user input file name for export
DxfFileName = InputBox("input dxf file name (no extension)", "save dxf for waterjet or laser")
' export file
DWGeditor.ActiveDocument.Export "\\officeserver3\laser\inter-department-files\" + DxfFileName, "dxf", objSS
' remove highlight of selection set
objSS.Highlight False
' Show Userform
Me.Show
End Sub
Private Sub CommandButton4_Click()
' dimension the variables
Dim objSS As SelectionSet
Dim DxfFileName As String
Dim pnt1 As New DWGeditor.Point
Dim pnt2 As New DWGeditor.Point
'On Error Resume Next
DWGeditor.ActiveDocument.Activate
' add the selection set name to the drawing database
Set objSS = DWGeditor.ActiveDocument.SelectionSets.Add("SetName")
' Hide Userform
Me.Hide
' set a pointer to the point object by using the GetPoint method in VBA
Set pnt1 = ThisWorkspace.ActiveDocument.Utility.GetPoint(, "upper left of select box")
' set a pointer to the point object by using the GetPoint method in VBA
Set pnt2 = ThisWorkspace.ActiveDocument.Utility.GetPoint(, "lower right of select box")
' populate the selection set with the drawing entity objects
objSS.Select vicSelectionSetInsideWindow, pnt1, pnt2
' highlight all the entities in the selection set
objSS.Highlight True
' Have user input file name for export
DxfFileName = InputBox("input dxf file name (no extension)", "save dxf for waterjet or laser")
' export file
DWGeditor.ActiveDocument.Export "\\officeserver3\laser\inter-department-files\" + DxfFileName, "dxf", objSS
' remove highlight of selection set
objSS.Highlight False
' Show Userform
Me.Show
End Sub