Author Topic: Filter TypedValue Model Space  (Read 332 times)

0 Members and 1 Guest are viewing this topic.

sigster

  • Newt
  • Posts: 26
Filter TypedValue Model Space
« on: March 23, 2022, 06:48:03 AM »
Hi

How can I filter so I only select from Model space

if I use it like this the command just end

Dim filterfor As TypedValue() = {New TypedValue(0, "LINE,ARC,CIRCLE,SPLINE,LWPOLYLINE,ELLIPSE,INSERT,MTEXT,TEXT,POINT"), New TypedValue(410, "Model")}


Code: [Select]
         Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            If doc Is Nothing Then Return
            Dim ed As Editor = doc.Editor


            '  Dim filterfor As TypedValue() = {New TypedValue(0, "LINE,ARC,CIRCLE,SPLINE,LWPOLYLINE,ELLIPSE,INSERT,MTEXT,TEXT,POINT"), New TypedValue(410, "Model")}

            Dim filterfor As TypedValue() = {New TypedValue(0, "LINE,ARC,CIRCLE,SPLINE,LWPOLYLINE,ELLIPSE,INSERT,MTEXT,TEXT,POINT")}
            Dim sf As SelectionFilter = New SelectionFilter(filterfor)
            Dim rsSel As PromptSelectionResult = ed.SelectAll(sf)

            If rsSel.Status <> PromptStatus.OK OrElse rsSel.Value.Count = 0 Then Return
            Dim rsEnt As PromptEntityResult = ed.GetEntity("Select Polyline")
            If rsEnt.Status <> PromptStatus.OK Then Return

« Last Edit: March 23, 2022, 11:21:15 AM by sigster »

Jeff_M

  • King Gator
  • Posts: 4037
  • C3D user & customizer
Re: Filter TypedValue Model Space
« Reply #1 on: March 23, 2022, 10:26:05 AM »
The filter for ModelSpace works for me. I have 3 lines and 5 circles in modelspace and 10 lines in paperspace, the following code correctly returns the count as 3.
Code - C#: [Select]
  1.             var filter = new SelectionFilter(new TypedValue[] {new TypedValue(0, "LINE"), new TypedValue(410, "Model") });
  2.             var ss = ed.SelectAll(filter);
  3.             var count = ss.Value.Count;
  4.  

sigster

  • Newt
  • Posts: 26
Re: Filter TypedValue Model Space
« Reply #2 on: March 23, 2022, 11:08:50 AM »


Thanks

Sett it up like you and then it work

Code: [Select]

'This work
         Dim filter = New SelectionFilter(New TypedValue() {New TypedValue(0, "LWPOLYLINE"), New TypedValue(410, "Model")})
            Dim rsSel As PromptSelectionResult = ed.SelectAll(filter)

'This dont work
Dim filterfor As TypedValue() = {New TypedValue(0, "LINE,ARC,CIRCLE,SPLINE,LWPOLYLINE,ELLIPSE,INSERT,MTEXT,TEXT,POINT"), New TypedValue(410, "Model space")}


sigster

  • Newt
  • Posts: 26
Re: Filter TypedValue Model Space [solved]
« Reply #3 on: March 23, 2022, 11:21:04 AM »


"LINE,POINT" is the proble if I use only LINE it work but if I add more type like "LINE,POINT" the command end

sigster

  • Newt
  • Posts: 26
Re: Filter TypedValue Model Space [solved]
« Reply #4 on: March 23, 2022, 11:39:10 AM »


Work like this :)  solved

Code: [Select]

      Dim acTypValAr(1) As TypedValue
            acTypValAr.SetValue(New TypedValue(DxfCode.Start, "INSERT,LINE,LWPOLYLINE,MTEXT,TEXT,POINT"), 0)
            acTypValAr.SetValue(New TypedValue(DxfCode.LayerName, "LAYERNAME"), 1)