.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Point selection gets wrong points

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
snappyjazz
768 Views, 16 Replies

Point selection gets wrong points

Hello,

I wrote a program that prints to pdf the window you pick. The window is two promptpointoptions. I should note that in most dwgs, this works; but some drawings the points that get returned aren't what I selected. I copied (and modified) the getwindow code from another post and I can't find it again (go figure). I'm not sure what is different between the dwg's this works on vs the drawings it doesn't work on. I'm not sure what tree to start shaking. Can anyone give me guidance?

 

#Region " Emp_PDF_Window_FitToA"
    <CadRun.CommandMethod("Emp_PDF_Window_FitToA")>
    Public Sub Emp_PDF_Window_FitToA()
        Initiate()
        ' Exit if printer is busy
        If CadPrint.PlotFactory.ProcessPlotState <> CadPrint.ProcessPlotState.NotPlotting Then : g_AcDoc.Editor.WriteMessage(vbLf & "Another plot is in progress.") : DB.WriteLine(vbNewLine & "Class1 | Emp_Window_FitToA | Another plot is in progress." & vbNewLine) : Exit Sub : End If
        ' Get and set the system variable values
        Dim backPlot As Object = CadApp.Application.GetSystemVariable("BACKGROUNDPLOT") : CadApp.Application.SetSystemVariable("BACKGROUNDPLOT", 0)
        Dim SnapSet As Object = CadApp.Application.GetSystemVariable("OSMODE") : CadApp.Application.SetSystemVariable("OSMODE", 0)

        Dim Trans As CadDBS.Transaction = g_AcDatBas.TransactionManager.StartTransaction()
        Dim BlTblRec As CadDBS.BlockTableRecord = CType(Trans.GetObject(g_AcDatBas.CurrentSpaceId, CadDBS.OpenMode.ForRead), CadDBS.BlockTableRecord)
        Dim PlotInfo As CadPrint.PlotInfo = New CadPrint.PlotInfo
        Dim PlSet As CadDBS.PlotSettings = New CadDBS.PlotSettings(g_ActiveLayout.Layout.ModelType)
        Dim PlSetVal As CadDBS.PlotSettingsValidator = CadDBS.PlotSettingsValidator.Current
        Dim PlStyle As New PlotStyle
        Dim PrPl As New PrinterPlotter

        Try
            Dim WinCoord As CadDBS.Extents2d = GetWindow()
            PlotInfo.Layout = BlTblRec.LayoutId

            ' API makes sure that the new "plotsettings" is initialized correctly.
            Dim plSets As CadDBS.DBDictionary = Trans.GetObject(g_AcDatBas.PlotSettingsDictionaryId, CadDBS.OpenMode.ForRead)

            ' Check to see if the page setup exists
            If plSets.Contains("EZ-Print-PDF-Window-A-Scale_To_Fit") = False Then
                PrintObj(ShtSizeEnum.A, FitOrScaleEnum.Fit, g_ActiveLayout.Layout, g_ActiveLayout.Standard, True, WinCoord)
                PlSet = plSets.GetAt("EZ-Print-PDF-Window-A-Scale_To_Fit").GetObject(CadDBS.OpenMode.ForWrite)
            Else
                PlSet = plSets.GetAt("EZ-Print-PDF-Window-A-Scale_To_Fit").GetObject(CadDBS.OpenMode.ForWrite)
            End If

        'Add these plot settings to the plot settings dictionary
        PlSet.AddToPlotSettingsDictionary(g_AcDatBas)

            ' Refresh the plot settings with plot settings validator
            PlSetVal.RefreshLists(PlSet)

            ' Update the plot info with the plot settings
            PlotInfo.OverrideSettings = PlSet
            Dim PlotInfoVal As CadPrint.PlotInfoValidator = New CadPrint.PlotInfoValidator
            PlotInfoVal.MediaMatchingPolicy = CadPrint.MatchingPolicy.MatchEnabled
            PlotInfoVal.Validate(PlotInfo)

        PreviewOrPlotWithDialog(PlotInfo, False, True, g_DefaultPdfFileName)

        PlSet.Dispose()
            Trans.Commit()

            ' Regenerate the document
            g_AcDoc.Editor.Regen()

            ' Restore the previous value for the system variables
            CadApp.Application.SetSystemVariable("BACKGROUNDPLOT", backPlot)
            CadApp.Application.SetSystemVariable("OSMODE", SnapSet)

        Catch ex As Exception
            Exit Sub
        End Try
    End Sub
#End Region

#Region " GetWindow | Public Function"
    Public Function GetWindow() As CadDBS.Extents2d
        'Dim PrptResult As CadEdIn.PromptSelectionResult = g_AcDoc.Editor.SelectWindow
        Dim PPO As CadEdIn.PromptPointOptions = New CadEdIn.PromptPointOptions(vbLf & "Select first corner of plot area: ")
        Try : PPO = New CadEdIn.PromptPointOptions(vbLf & "Select first corner of plot area: ")
        Catch ex As Exception : Return Nothing : Exit Function : End Try
        PPO.AllowNone = False
        Dim PPR As CadEdIn.PromptPointResult = g_AcDoc.Editor.GetPoint(PPO)
        If PPR.Status <> CadEdIn.PromptStatus.OK Then : Exit Function : End If
        Dim FirstPnt As CadGeo.Point3d = PPR.Value
        g_AcDoc.Editor.WriteMessage(vbTab & "(" & FirstPnt.X & ", " & FirstPnt.Y & ", " & FirstPnt.Z & ")")
       
        Dim PCO As CadEdIn.PromptCornerOptions
        Try : PCO = New CadEdIn.PromptCornerOptions(vbLf & "Select second corner of plot area: ", FirstPnt)
        Catch ex As Exception : Return Nothing : Exit Function : End Try
        PPR = g_AcDoc.Editor.GetCorner(PCO)
        If PPR.Status <> CadEdIn.PromptStatus.OK Then : Exit Function : End If
        Dim SecondPnt As CadGeo.Point3d = PPR.Value
        g_AcDoc.Editor.WriteMessage(vbTab & "(" & SecondPnt.X & ", " & SecondPnt.Y & ", " & SecondPnt.Z & ")" & vbLf)
        
        Dim FromResltBuf As CadDBS.ResultBuffer = New CadDBS.ResultBuffer(New CadDBS.TypedValue(5003, 1))
        Dim ToResltBuf As CadDBS.ResultBuffer = New CadDBS.ResultBuffer(New CadDBS.TypedValue(5003, 2))
        Dim FirstRes As Double() = New Double() {FirstPnt.X, FirstPnt.Y, FirstPnt.Z}
        Dim SecondRes As Double() = New Double() {SecondPnt.X, SecondPnt.Y, SecondPnt.Z}

        ' Remove the Z element from the first and second results
        Dim Window As CadDBS.Extents2d = New CadDBS.Extents2d(FirstRes(0), FirstRes(1), SecondRes(0), SecondRes(1))

        Return Window
    End Function
    Private Function AcEdTrans(ByVal Point As Double(), ByVal FromResBuf As IntPtr, ByVal ToResBuf As IntPtr, ByVal Disp As Integer, ByVal Result As Double()) As Integer : End Function
#End Region

 

16 REPLIES 16
Message 2 of 17
hippe013
in reply to: snappyjazz

I have a couple of comments. 

 

First you most likely have some code missing. It would be easier to test the code if it came more or less complete. 

 

Second, now this is my opinion, you have an overuse of namespace abbreviations.  Just import your namespaces; no need to abbreviate everything.  It just makes your code difficult to read and difficult for others to test and debug. If you have that many namespace conflicts then you may want to look to see if you are putting you code in the right spots. (ie, your entire code set is in one file, not good.)

 

Third, again this is my opinion, you have an overuse of colons. Sometimes the use of colons make sense. Little snippets that can fit on one line of code. Sure use a colon, but not for every single line of code. 

 

 

a = 2.3 : b = 6.7 : c = 0.2

 

 

Fourth. Your function GetWindow is mixing old style code with new. A try/catch is not needed for creating promptOptions. No need for the result buffers or the arrays of doubles.  See the following refactored  GetWindow function:

 

Public Function GetWindow() As Extents2d
   Dim ppo As New PromptPointOptions(vbCrLf & "Select First Corner of Plot Area: ")
   Dim ppr As PromptPointResult = ed.GetPoint(ppo)

   If ppr.Status <> PromptStatus.OK Then
      Return New Extents2d() 'Need to then test for zero extents (bad result)
   End If

   Dim pco As New PromptCornerOptions(vbCrLf & "Select second corner of plot area: ", ppr.Value)
   Dim pcr As PromptPointResult = ed.GetCorner(pco)

   If pcr.Status <> PromptStatus.OK Then
      Return New Extents2d 'Need to then test for zero extents (bad result)
   End If

   Dim p1 As New Point2d(ppr.Value.X, ppr.Value.Y)
   Dim p2 As New Point2d(pcr.Value.X, pcr.Value.Y)

   Return New Extents2d(p1, p2)

End Function

 

It will return an extents2d with 0,0 and 0,0 as the points if the user presses escape. You will want to test for that. 

 

I think that this is a start and hope that it helps. 

 

Message 3 of 17
snappyjazz
in reply to: hippe013

Thank you. That did clean up my code. I still have an issue with the wrong points. Although a new development on this is when you don't use a 1st quadrant window. Where if your first point is considered the origin of the quadrant system and your second point isn't in the first quadrant, Acad will use the x coordinate as a horizontal distance to the right, and use the y coordinate as a vertical distance up. I need to figure out how to check which quadrant the 2nd point is in and add/subtract as necessary.

 

Side note: Is this why other posts ask about converting to World Coordinate System?

Also not sure, maybe this could be a setting? that would make this much easier

 

snappyjazz_0-1680122685267.png

 

Message 4 of 17
hippe013
in reply to: snappyjazz

Without seeing your full code I wouldn't be able to say one way or another. The PrintObj subroutine definition is not included in the code that you provided. 

Message 5 of 17
snappyjazz
in reply to: hippe013

#Region " PrintObj | Public Sub"
    Public Sub PrintObj(ByVal ShtSize As ShtSizeEnum, ByVal FitOrScale As FitOrScaleEnum, ByRef Layout As CadDBS.Layout, ByVal Std As ShtStandardEnum, Optional ByVal PrintPDF As Boolean = False, Optional ByVal WindowCoord As CadDBS.Extents2d = Nothing)
        'DB.WriteLine(vbNewLine & $"Globals | PrintObj | Submitted info: Sheet Size: {ShtSize.ToString} | Fit or Scale: {FitOrScale.ToString} | Layout Name: {Layout.LayoutName} | Print Pdf: {PrintPDF.ToString} | Window Coordinates: {WindowCoord.ToString}" & vbNewLine)
        'Dim Plset As New PlSettings
        Dim PlSet As CadDBS.PlotSettings = New CadDBS.PlotSettings(True)
        Dim PlSetVal As CadDBS.PlotSettingsValidator = CadDBS.PlotSettingsValidator.Current
        Dim PP As New PrinterPlotter
        Dim PPS As New PlotPaperSize
        Dim SN As New PlotStyle
        Dim Trans As CadDBS.Transaction = g_AcDatBas.TransactionManager.StartTransaction()
        Dim CreateNew As Boolean
        Dim PlSetName As String
        Dim PlSets As CadDBS.DBDictionary = Trans.GetObject(g_AcDatBas.PlotSettingsDictionaryId, CadDBS.OpenMode.ForRead)

#Region " Page Setup Name"
        Select Case True
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.A AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Printer-A-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.B AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Printer-B-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.C AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Plotter-C-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.D AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Plotter-D-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.E AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Plotter-E-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.A AndAlso Not PrintPDF AndAlso WindowCoord <> Nothing : PlSetName = "EZ-Print-Window-A-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.B AndAlso Not PrintPDF AndAlso WindowCoord <> Nothing : PlSetName = "EZ-Print-Window-B-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.A AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Printer-A-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.B AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Printer-B-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.C AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Plotter-C-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.D AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Plotter-D-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.E AndAlso Not PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-DD_Plotter-E-To_Scale"
                '--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.A AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-A-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.B AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-B-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.C AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-C-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.D AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-D-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.E AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-E-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.A AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-A-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.B AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-B-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.C AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-C-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.D AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-D-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Scale AndAlso ShtSize = ShtSizeEnum.E AndAlso PrintPDF AndAlso WindowCoord = Nothing : PlSetName = "EZ-Print-PDF-E-To_Scale"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.A AndAlso PrintPDF AndAlso WindowCoord <> Nothing : PlSetName = "EZ-Print-PDF-Window-A-Scale_To_Fit"
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.B AndAlso PrintPDF AndAlso WindowCoord <> Nothing : PlSetName = "EZ-Print-PDF-Window-B-Scale_To_Fit"
        End Select
#End Region

#Region " Handle page setup"
        ' Check to see if the page setup exists
        If Not PlSets.Contains(PlSetName) Then
            'DB.WriteLine(vbNewLine & $"Globals | PrintObj | Page Setup ({PlSetName}) does not exist - building it." & vbNewLine)
            CreateNew = True

            ' Create a new PlotSettings object: 
            '    True - model space, False - named layout
            PlSet = New CadDBS.PlotSettings(Layout.ModelType) '<-- not used when copy and pasted
            ' Use CopyFrom property of the plotsetting to initialize it on the layout
            PlSet.CopyFrom(Layout) ' API makes sure that the new "PlotSettings" is initialized correctly.

            ' Set the name of the Plot Settings (Page Setup)
            PlSet.PlotSettingsName = PlSetName

            ' Add to the plot settings dictionary (Adds to the drawing database)
            PlSet.AddToPlotSettingsDictionary(g_AcDatBas)

            ' Adds the plot settings to the transaction
            Trans.AddNewlyCreatedDBObject(PlSet, True)

            ' Refreshing the plot settings with plot settings validator
            PlSetVal.RefreshLists(PlSet)

        Else
            PlSet = PlSets.GetAt(PlSetName).GetObject(CadDBS.OpenMode.ForWrite)
        End If
#End Region

#Region " Set unique settings"
        Select Case True
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.A AndAlso Not PrintPDF
                PlSetVal.SetPlotConfigurationName(PlSet, PP.DDPrinter, PPS.DD_Ansi_A)
                PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees090)

            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.B AndAlso Not PrintPDF
                PlSetVal.SetPlotConfigurationName(PlSet, PP.DDPrinter, PPS.DD_Ansi_B)
                PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees090)

            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.C AndAlso Not PrintPDF
                PlSetVal.SetPlotConfigurationName(PlSet, PP.DdPlotter, PPS.DD_Arch_C)
                PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees000)

            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.D AndAlso Not PrintPDF
                PlSetVal.SetPlotConfigurationName(PlSet, PP.DdPlotter, PPS.DD_Arch_D)
                PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees000)

            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.E AndAlso Not PrintPDF
                PlSetVal.SetPlotConfigurationName(PlSet, PP.DdPlotter, PPS.DD_Arch_E)
                PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees090)
                '--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/--PDF--\/
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.A AndAlso Std = ShtStandardEnum.Ansi AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_A)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.B AndAlso Std = ShtStandardEnum.Ansi AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_B)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.C AndAlso Std = ShtStandardEnum.Ansi AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_C)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.D AndAlso Std = ShtStandardEnum.Ansi AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_D)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.E AndAlso Std = ShtStandardEnum.Ansi AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_E)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.A AndAlso Std = ShtStandardEnum.Arch AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_A)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.B AndAlso Std = ShtStandardEnum.Arch AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_B)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.C AndAlso Std = ShtStandardEnum.Arch AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_C)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.D AndAlso Std = ShtStandardEnum.Arch AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_D)
            Case FitOrScale = FitOrScaleEnum.Fit AndAlso ShtSize = ShtSizeEnum.E AndAlso Std = ShtStandardEnum.Arch AndAlso PrintPDF : PlSetVal.SetPlotConfigurationName(PlSet, PP.PdfPlotter, PPS.PDF_Ansi_E)
        End Select
#End Region

        PlSetVal = CadDBS.PlotSettingsValidator.Current '<-- not used when copy and pasted
        PlSet.ShowPlotStyles = True
        PlSet.ShadePlot = CadDBS.PlotSettingsShadePlotType.AsDisplayed
        PlSet.ShadePlotResLevel = CadDBS.ShadePlotResLevel.Normal
        PlSet.ShadePlotCustomDpi = 300
        PlSet.PlotHidden = False
        PlSet.PrintLineweights = False
        PlSet.ScaleLineweights = False
        PlSet.DrawViewportsFirst = False
        If WindowCoord = Nothing Then : PlSetVal.SetPlotWindowArea(PlSet, Layout.Limits) : Else : PlSetVal.SetPlotWindowArea(PlSet, WindowCoord) : End If  '<-- Used with Window plot type
        PlSetVal.SetPlotType(PlSet, CadDBS.PlotType.Window)
        PlSetVal.SetStdScaleType(PlSet, CadDBS.StdScaleType.ScaleToFit) '<-- Used with Window Plot Type. This is greyed out when using layout plot type
        'PlSetVal.SetPlotType(PlSet, CadDBS.PlotType.Extents)
        PlSetVal.SetPlotCentered(PlSet, True) '<-- Center is greyed out when plot area (Type) is set to "Layout"
        If PlSetVal.GetPlotStyleSheetList().Contains(SN.Monochrome.ToString) Then : PlSetVal.SetCurrentStyleSheet(PlSet, SN.Monochrome.ToString) : Else : DB.WriteLine(vbNewLine & $"Globals | PrintObj | Couldn't load {SN.Monochrome.ToString} style." & vbNewLine) : End If

        Trans.Commit()
        PlSet.Dispose()
        PlSetVal.Dispose()

    End Sub
#End Region

#Region " FitOrScaleEnum"
    Public Enum FitOrScaleEnum
        Fit
        Scale
    End Enum
#End Region

#Region " ShtSizeEnum"
    Public Enum ShtSizeEnum
        A
        B
        C
        D
        E
    End Enum
#End Region

#Region " ShtStandardEnum"
    Public Enum ShtStandardEnum
        Ansi
        Arch
        NotAvailable
    End Enum
#End Region

#Region " PlotPaperSize | Public Class"
    Public Class PlotPaperSize
        ' DD-Printer \\NetworkDir\R-DD_ADMIN_COPY
        ' DD-Plotter dd_eng_plotter on NetworkDir (vdi) : Roll 1 = 36" | Roll 2 = 24"
        ' DWG To PDF.pc3        
        Public Shared DdPrinterMediaList As List(Of String) = New List(Of String) From {"Letter", "Legal", "Tabloid", "Executive", "Statement", "304 842 1190", "305 595 842", "A2 420 x 594 mm", "A3", "A4", "A5", "A6 105 x 148 mm", "306 729 1031", "307 516 729", "308 365 516", "B4 (JIS)", "B5 (JIS)", "B6 (JIS) 128 x 182 mm", "278 306 458", "273 271 391", "274 196 271", "Japanese Postcard 100 x 148 mm", "281 103 153", "Envelope #10", "Envelope B5", "Envelope DL", "Envelope Monarch", "Envelope C4", "Envelope C5", "Envelope C6", "314 99 149", "Japanese Envelope You #4", "Japanese Envelope Chou #3", "Japanese Envelope Chou #4", "315 271 383", "Japanese Envelope Kaku #2", "Japanese Envelope Kaku #3", "271 204 331", "282 211 331", "Folio", "295 217 344", "283 207 338", "280 221 331", "504 298 421", "284 211 298", "285 149 211", "286 258 365", "287 183 258", "288 280 433", "290 217 280", "291 141 217", "500 227 298", "499 232 280", "494 321 451", "256 217 280"}
        Public Shared DdPlotterMediaList As List(Of String) = New List(Of String) From {"Letter", "Legal", "Tabloid", "C size sheet", "D size sheet", "E size sheet", "4448 230 306", "4446 306 458", "4444 458 611", "4442 611 915", "4434 915 1220", "256 211 298", "4436 763 1068", "4438 661 966", "4440 687 992", "4401 842 1190", "4403 595 842", "4520 433 611", "A2 420 x 594 mm", "4406 330 484", "A3", "A4", "4416 1001 1415", "4418 708 1001", "4420 501 708", "4422 354 501", "B4 (ISO) 250 x 353 mm", "4408 1031 1457", "4410 729 1031", "4412 516 729", "4414 365 516", "B4 (JIS)", "4428 712 1017", "4432 331 484", "4482 918 1298", "4450 649 918", "4452 459 649", "4454 325 459", "4456 230 325", "4497 509 611", "4495 458 560", "4493 357 433", "4515 306 407", "4491 255 306", "4511 255 382", "4466 204 255", "4513 407 509", "4458 509 763", "4460 763 1017", "4484 1068 1525", "4485 1119 1576", "4519 301 901", "4480 330 559"}
        ' Arch A: "4448 230 306" | Arch B: "4446 306 458" | Arch C: "4444 458 611" | Arch 😧 "4442 611 915" | Arch E: "4434 915 1220 | Custom Size: 256 211 298"
        Public Shared DdPdfMediaList As List(Of String) = New List(Of String) From {"ANSI_full_bleed_F_(28.00_x_40.00_Inches)", "ANSI_full_bleed_E_(34.00_x_44.00_Inches)", "ANSI_full_bleed_D_(34.00_x_22.00_Inches)", "ANSI_full_bleed_D_(22.00_x_34.00_Inches)", "ANSI_full_bleed_C_(22.00_x_17.00_Inches)", "ANSI_full_bleed_C_(17.00_x_22.00_Inches)", "ANSI_full_bleed_B_(17.00_x_11.00_Inches)", "ANSI_full_bleed_B_(11.00_x_17.00_Inches)", "ANSI_full_bleed_A_(11.00_x_8.50_Inches)", "ANSI_full_bleed_A_(8.50_x_11.00_Inches)", "ARCH_full_bleed_E1_(30.00_x_42.00_Inches)", "ARCH_full_bleed_E_(36.00_x_48.00_Inches)", "ARCH_full_bleed_D_(36.00_x_24.00_Inches)", "ARCH_full_bleed_D_(24.00_x_36.00_Inches)", "ARCH_full_bleed_C_(24.00_x_18.00_Inches)", "ARCH_full_bleed_C_(18.00_x_24.00_Inches)", "ARCH_full_bleed_B_(18.00_x_12.00_Inches)", "ARCH_full_bleed_B_(12.00_x_18.00_Inches)", "ARCH_full_bleed_A_(12.00_x_9.00_Inches)", "ARCH_full_bleed_A_(9.00_x_12.00_Inches)", "ISO_full_bleed_B5_(250.00_x_176.00_MM)", "ISO_full_bleed_B5_(176.00_x_250.00_MM)", "ISO_full_bleed_B4_(353.00_x_250.00_MM)", "ISO_full_bleed_B4_(250.00_x_353.00_MM)", "ISO_full_bleed_B3_(500.00_x_353.00_MM)", "ISO_full_bleed_B3_(353.00_x_500.00_MM)", "ISO_full_bleed_B2_(707.00_x_500.00_MM)", "ISO_full_bleed_B2_(500.00_x_707.00_MM)", "ISO_full_bleed_B1_(1000.00_x_707.00_MM)", "ISO_full_bleed_B1_(707.00_x_1000.00_MM)", "ISO_full_bleed_B0_(1414.00_x_1000.00_MM)", "ISO_full_bleed_B0_(1000.00_x_1414.00_MM)", "ISO_full_bleed_A5_(210.00_x_148.00_MM)", "ISO_full_bleed_A5_(148.00_x_210.00_MM)", "ISO_full_bleed_2A0_(1189.00_x_1682.00_MM)", "ISO_full_bleed_4A0_(1682.00_x_2378.00_MM)", "ISO_full_bleed_A4_(297.00_x_210.00_MM)", "ISO_full_bleed_A4_(210.00_x_297.00_MM)", "ISO_full_bleed_A3_(420.00_x_297.00_MM)", "ISO_full_bleed_A3_(297.00_x_420.00_MM)", "ISO_full_bleed_A2_(594.00_x_420.00_MM)", "ISO_full_bleed_A2_(420.00_x_594.00_MM)", "ISO_full_bleed_A1_(841.00_x_594.00_MM)", "ISO_full_bleed_A1_(594.00_x_841.00_MM)", "ISO_full_bleed_A0_(841.00_x_1189.00_MM)", "ISO_expand_A0_(841.00_x_1189.00_MM)", "ISO_A0_(841.00_x_1189.00_MM)", "ISO_expand_A1_(841.00_x_594.00_MM)", "ISO_expand_A1_(594.00_x_841.00_MM)", "ISO_A1_(841.00_x_594.00_MM)", "ISO_A1_(594.00_x_841.00_MM)", "ISO_expand_A2_(594.00_x_420.00_MM)", "ISO_expand_A2_(420.00_x_594.00_MM)", "ISO_A2_(594.00_x_420.00_MM)", "ISO_A2_(420.00_x_594.00_MM)", "ISO_expand_A3_(420.00_x_297.00_MM)", "ISO_expand_A3_(297.00_x_420.00_MM)", "ISO_A3_(420.00_x_297.00_MM)", "ISO_A3_(297.00_x_420.00_MM)", "ISO_expand_A4_(297.00_x_210.00_MM)", "ISO_expand_A4_(210.00_x_297.00_MM)", "ISO_A4_(297.00_x_210.00_MM)", "ISO_A4_(210.00_x_297.00_MM)", "ARCH_expand_E1_(30.00_x_42.00_Inches)", "ARCH_E1_(30.00_x_42.00_Inches)", "ARCH_expand_E_(36.00_x_48.00_Inches)", "ARCH_E_(36.00_x_48.00_Inches)", "ARCH_expand_D_(36.00_x_24.00_Inches)", "ARCH_expand_D_(24.00_x_36.00_Inches)", "ARCH_D_(36.00_x_24.00_Inches)", "ARCH_D_(24.00_x_36.00_Inches)", "ARCH_expand_C_(24.00_x_18.00_Inches)", "ARCH_expand_C_(18.00_x_24.00_Inches)", "ARCH_C_(24.00_x_18.00_Inches)", "ARCH_C_(18.00_x_24.00_Inches)", "ANSI_expand_E_(34.00_x_44.00_Inches)", "ANSI_E_(34.00_x_44.00_Inches)", "ANSI_expand_D_(34.00_x_22.00_Inches)", "ANSI_expand_D_(22.00_x_34.00_Inches)", "ANSI_D_(34.00_x_22.00_Inches)", "ANSI_D_(22.00_x_34.00_Inches)", "ANSI_expand_C_(22.00_x_17.00_Inches)", "ANSI_expand_C_(17.00_x_22.00_Inches)", "ANSI_C_(22.00_x_17.00_Inches)", "ANSI_C_(17.00_x_22.00_Inches)", "ANSI_expand_B_(17.00_x_11.00_Inches)", "ANSI_expand_B_(11.00_x_17.00_Inches)", "ANSI_B_(17.00_x_11.00_Inches)", "ANSI_B_(11.00_x_17.00_Inches)", "ANSI_expand_A_(11.00_x_8.50_Inches)", "ANSI_expand_A_(8.50_x_11.00_Inches)", "ANSI_A_(11.00_x_8.50_Inches)", "ANSI_A_(8.50_x_11.00_Inches)"}

        Public Sub New()

        End Sub

        
        Public Property DD_CustomPlot As String = GetSize(,,,, True)
        Public Property DD_Ansi_A As String = DdPrinterMediaList.Item(0)
        Public Property DD_Ansi_B As String = DdPrinterMediaList.Item(2)
        Public Property DD_Ansi_C As String = DdPlotterMediaList.Item(3)
        Public Property DD_Ansi_D As String = DdPlotterMediaList.Item(4)
        Public Property DD_Ansi_E As String = DdPlotterMediaList.Item(5)
        Public Property DD_Arch_A As String = DdPrinterMediaList.Item(0)
        Public Property DD_Arch_B As String = DdPrinterMediaList.Item(2)
        Public Property DD_Arch_C As String = DdPlotterMediaList.Item(8)
        Public Property DD_Arch_D As String = DdPlotterMediaList.Item(9)
        Public Property DD_Arch_E As String = DdPlotterMediaList.Item(10)

        Public Property PDF_Ansi_A As String = DdPdfMediaList.Item(9)
        Public Property PDF_Ansi_B As String = DdPdfMediaList.Item(7)
        Public Property PDF_Ansi_C As String = DdPdfMediaList.Item(4)
        Public Property PDF_Ansi_D As String = DdPdfMediaList.Item(2)
        Public Property PDF_Ansi_E As String = DdPdfMediaList.Item(1)
        Public Property PDF_Arch_A As String = DdPdfMediaList.Item(19)
        Public Property PDF_Arch_B As String = DdPdfMediaList.Item(17)
        Public Property PDF_Arch_C As String = DdPdfMediaList.Item(14)
        Public Property PDF_Arch_D As String = DdPdfMediaList.Item(12)
        Public Property PDF_Arch_E As String = DdPdfMediaList.Item(11)

    End Class
#End Region

#Region " PrinterPlotter | Public Class"
    Public Class PrinterPlotter
        Public Property DDPrinter As String = "\\NetworkDir\R-DD_ADMIN_COPY"

        Public Property DdPlotter As String = "dd_eng_plotter on NetworkDir (vdi)"
        ' Roll 1 = 36" | Roll 2 = 24"
        Public Property PdfPlotter As String = "DWG To PDF.pc3"
        'Public Property PdfPlotter As String = "DWF6 ePlot.pc3"
    End Class
#End Region
Message 6 of 17
hippe013
in reply to: snappyjazz

 

 

If WindowCoord = Nothing Then : PlSetVal.SetPlotWindowArea(PlSet, Layout.Limits) : Else : PlSetVal.SetPlotWindowArea(PlSet, WindowCoord) : End If  '<-- Used with Window plot type

 


 

I am not saying that this is what is causing your issues but this is the first thing that pops out to me. You are testing if windowCoord is nothing. WindowCoord value is an Extends2d which is a Stucture which is a value type and not a reference type like a class is. A value type cannot be nothing. A value type set to nothing would set the values to the default values. 

 

Does this coincide with your testing?

Message 7 of 17
snappyjazz
in reply to: hippe013

I suppose I'm too close to the project and that made sense to me, but to someone else reading the code it is confusing. In the PrintObj - WindowCoord is an optional parameter of the sub. I set the default value for it as nothing. Unless I misunderstand then I should change that "nothing" to a blank extents object, and test for a blank extents as well. I can change that, but adding a converter to the points seems to be working. Its preliminary and I'm still testing.

 

#Region " GetWindow | Public Function"
    Public Function GetWindow() As CadDBS.Extents2d
        ' Get the first point
        Dim Pnt1Prompt As CadEdIn.PromptPointOptions = New CadEdIn.PromptPointOptions(vbLf & "Select first corner of plot area: ")
        Dim Pnt1 As CadEdIn.PromptPointResult = g_AcDoc.Editor.GetPoint(Pnt1Prompt)
        If Pnt1.Status <> CadEdIn.PromptStatus.OK Then : Return New CadDBS.Extents2d : End If ' Return blank extents [(0,0), (0,0)] if escape is pressed
        g_AcDoc.Editor.WriteMessage(vbTab & "(" & Pnt1.Value.X & ", " & Pnt1.Value.Y & ", " & Pnt1.Value.Z & ")")

        Dim Pnt2Prompt As CadEdIn.PromptCornerOptions = New CadEdIn.PromptCornerOptions(vbLf & "Select second corner of plot area: ", Pnt1.Value)
        Dim Pnt2 As CadEdIn.PromptPointResult = g_AcDoc.Editor.GetCorner(Pnt2Prompt)
        If Pnt1.Status <> CadEdIn.PromptStatus.OK Then : Return New CadDBS.Extents2d : End If ' Return blank extents [(0,0), (0,0)] if escape is pressed
        g_AcDoc.Editor.WriteMessage(vbTab & "(" & SecondPnt.X & ", " & SecondPnt.Y & ", " & SecondPnt.Z & ")" & vbLf)

        ' Convert the window points to a quadrant 1 selection window.
        ' The print coordinates only accept the first point as being
        ' the bottom left and the second point as being top right.
        Dim QuadExt As CadDBS.Extents2d = ConvertToQuad1(Pnt1.value, Pnt2.Value)

        Return QuadExt
    End Function
    ' Private Function AcEdTrans(ByVal Point As Double(), ByVal FromResBuf As IntPtr, ByVal ToResBuf As IntPtr, ByVal Disp As Integer, ByVal Result As Double()) As Integer : End Function
#End Region

#Region " ConvertToQuad1 | Public Function"
Public Function ConvertToQuad1(ByVal Pnt1 as CadGeo.Point3d, ByVal Pnt2 As CadGeo.Point3d) As CadDBS.Extents2d
    Dim IsRight As Boolean = False
    Dim IsAbove As Boolean = False

    ' Check if point 2 is on the right side of point 1
    If Pnt1.X < Pnt2.X Then : IsRight = True : End If

    ' Check if point 2 is above point 1
    If Pnt1.Y < Pnt2.Y Then : IsAbove = True : End If

    Select Case True
        Case IsRight = True AndAlso IsAbove = True
            ' Quad 1: pnt 2 is to the right and above
            ' No need to convert
            Return New CadDBS.Extents2d(Pnt1.X, Pnt1.Y, Pnt2.X, Pnt2.Y)
        Case IsRight = False AndAlso IsAbove = True
            ' Quad 2: pnt 2 is to the left and above
            ' pnt2x & pnt1y is btm left, pnt1x & pnt2y is top right
            Return New CadDBS.Extents2d(Pnt2.X, Pnt1.Y, Pnt1.X, Pnt2.Y)
        Case IsRight = False AndAlso IsAbove = True
            ' Quad 3: pnt 2 is to the left and below
            ' reverse the points
            Return New CadDBS.Extents2d(Pnt2.X, Pnt2.Y, Pnt1.X, Pnt1.Y)
        Case IsRight = False AndAlso IsAbove = True
            ' Quad 4: pnt 2 is to the right and below
            ' pnt1x & pnt2y is btm left, pnt2x & pnt1y is top right
            Return New CadDBS.Extents2d(Pnt1.X, Pnt2.Y, Pnt2.X, Pnt1.Y)
    End Function
#End Region

 

Message 8 of 17
snappyjazz
in reply to: snappyjazz

I have tried changing the WindowCoord default value to a blank extents2d value, but I can't figure out how to. See my failures below.

 

snappyjazz_0-1680203874626.png

 

snappyjazz_1-1680203893032.png

 

snappyjazz_2-1680203906178.png

 

snappyjazz_3-1680203920354.png

 

Message 9 of 17
hippe013
in reply to: snappyjazz

Instead of making a structure a optional parameter. Try overloading your sub-routine. 

Message 10 of 17
Ed.Jobe
in reply to: snappyjazz

In the first and fourth images, you use 0 when the argument requires a double. Note the message in the fourth image mentions "integer, integer, integer, integer". You can use 0.0 or 0#. I'm not sure that it makes sense to create an extents that is a single point. None of your model would be visible. In the third image, you left off the parenthesis. Should be ..New CadDBS.Extents2d())

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 11 of 17
Ed.Jobe
in reply to: snappyjazz


@snappyjazz wrote:

Thank you. That did clean up my code. I still have an issue with the wrong points. Although a new development on this is when you don't use a 1st quadrant window. Where if your first point is considered the origin of the quadrant system and your second point isn't in the first quadrant, Acad will use the x coordinate as a horizontal distance to the right, and use the y coordinate as a vertical distance up. I need to figure out how to check which quadrant the 2nd point is in and add/subtract as necessary.

 

Side note: Is this why other posts ask about converting to World Coordinate System?

Also not sure, maybe this could be a setting? that would make this much easier

 


The quadrants are all included in the same coordinate system, WCS or otherwise. So the answer is NO. The sign of x or y tells you what quadrant you are in. Q1=+x,+y. Q2=-x,+y. Q3=-x,-y. Q4=+x,-y.

 

I think what is complicating matters is that it appears you are trying to plot from model space. Most of us old timers don't recommend that. That's why paper space was invented for 30+ years ago. Multiple plot areas are just multiple PS layouts. A big bonus is that you can use the PUBLISH command or sheetsets to batch plot. If you specify a plotter and paper size, your plot area is just the Layout. Done. LL is always 0,0 of Q1, btw. You still can specify a window to plot, but that is usually only used when the user wants to just plot a zoomed in area rather than the whole layout.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 12 of 17
snappyjazz
in reply to: Ed.Jobe

@hippe013  Thanks I did end up overloading the printobj

@Ed.Jobe Hello, Thanks for helping. I am trying to print from both model space and paper space. The guys here often print specific areas of the drawings for markups and discussion. If I understand your explanation for the quadrants, and correct me if I'm wrong but you're saying that based on what side of the origin your on would tell you what quadrant you're in; and I would agree with you. Our dwg's have the origin set to the bottom left corner (first screenshot), so all of the window selection points are from q1. I'm referring the quadrant that the second window point is from the first window point (see screenshots 2 - 5).  The print window area seems to misinterpret my selection points (see the last couple of screenshots). It seems like it adds the values of the second point to the first point making a different window than what I selected, unless I make a window selection of q1. Does that make sense?

 

snappyjazz_0-1680281655844.png

 

snappyjazz_1-1680281675361.png

 

snappyjazz_2-1680281692347.png

 

snappyjazz_3-1680281711628.png

 

snappyjazz_4-1680281726120.png

 

snappyjazz_5-1680281740480.png

 

snappyjazz_6-1680281794661.png

 

Message 13 of 17
Ed.Jobe
in reply to: snappyjazz

In your Select..Case, you start swapping x and y from different points. Naturally, you won't have the same points the user chose. In the picture below, assume that all 4 cases enclose the same area. Pt1 and Pt2 are 2D points. The only variable is the order of selection (the relation of pt1 to pt2) and the only effect it has is to determine whether the window is crossing or non-crossing. It doesn't matter what quadrant the points are in or even if they are in the different quadrants. The selected window will always be the same... until you start swapping x1 for x2. A point is a location in space whose value is determined by the coordinate system. If you don't change coordinate systems in the middle of your command, the results should be consistent. I used Case 1-4, but it could have been Extents2d_1-4.

 

acad window selection.png

It might be an interesting extension method to create an IsCrossing property for an Extents.

 

**Thinking about it a little more..

The constructor for Extents2d is Extents2d.Extents2d (Point2d MinPoint, Point2d MaxPoint)

So it may depend on the definition of the Min/Max. To me the MinPoint has always been LowerLeft and MaxPoint is UpperRight. Someone else can confirm that. So, that represents Case 1 in the picture above. Since Extents2d is only a struct, not a class with some intelligence built into it. I doubt that if you allow case 2-4, then the constructor would interpret those cases. You may have to add some logic to always return MinPoint, MaxPoint to the Extents2d constructor.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 14 of 17
snappyjazz
in reply to: Ed.Jobe

@Ed.Jobe Your last paragraph "The constructor for extents2d is...MinPoint has always been LowerLeft and MaxPoint is UpperRight". I didn't know how to describe it that way so I just called it a quadrant 1(haha), I think you explained it better. I think you also gave me confidence in my "points converter" above when you said: "You may have to add some logic to always return MinPoint, MaxPoint to the Extents2d constructor"

Message 15 of 17
Ed.Jobe
in reply to: snappyjazz


@snappyjazz wrote:

I think you also gave me confidence in my "points converter" above when you said: "You may have to add some logic to always return MinPoint, MaxPoint to the Extents2d constructor"


You just need to make sure the logic is correct so you don't alter the window location.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 16 of 17
kdub_nz
in reply to: snappyjazz

@snappyjazz 

I get a headache reading and writing VB,  hence  the C#. This may give you some ideas.

 

Proof of Concept

 

 

 

 

 

[CommandMethod("TEST_0401")]
public void Select2dExtent()
{
   var doc = AcadApp.DocumentManager.MdiActiveDocument;
   var ed = doc.Editor;

   Point3d bp = default, cp = default, minPt = default, maxPt = default;
   PromptPointResult pointResult = default;

   // Select BasePoint
   PromptPointOptions promptPointOptions =
      new PromptPointOptions("Select BasePoint for Rectangle")
      {
         AllowArbitraryInput = true,
         AllowNone = false,
         LimitsChecked = true
      };
   pointResult = ed.GetPoint(promptPointOptions);

   if (pointResult.Status == PromptStatus.OK)
      bp = pointResult.Value;
   else
   {
      ed.WriteMessage("\n Invalid Base Point Selection.");
      return;
   }
   // Select Opposite Corner

   PromptCornerOptions cornerOptions =
      new PromptCornerOptions("Select opposite corner", bp)
      {
         AllowArbitraryInput = true,
         AllowNone = false,
         LimitsChecked = true,
         UseDashedLine = true
      };
   pointResult = ed.GetCorner(cornerOptions);
   if (pointResult.Status == PromptStatus.OK)
      cp = pointResult.Value;
   else
   {
      ed.WriteMessage("\n Invalid Corner Point Selection.");
      return;
   }

   ed.WriteMessage($"\nbp: {bp} \ncp: {cp}");

   Point3dCollection point3dCollection = new Point3dCollection
   {  bp,
      cp
   };

   Extents3d extents = new Extents3d();
   foreach (Point3d point in point3dCollection)
      extents.AddPoint(point);
   minPt = extents.MinPoint;
   maxPt = extents.MaxPoint;

   ed.WriteMessage(
      $"\nminPt: {Convert2d(minPt)} " +
      $"\nmaxPt: {Convert2d(maxPt)}");
}

public static Point2d Convert2d(Point3d pt)
{
   return new Point2d(pt.X, pt.Y);
}

 

 

 

 

 

 

Command: _.PSPACE
Command: TEST_0401
Select BasePoint for Rectangle: Select opposite corner:
bp: (65.657928507552,49.0238115360263,0)
cp: (120.xxx-xxxxxxxx,102.427805337222,0)
minPt: (65.657928507552,49.0238115360263)
maxPt: (120.xxx-xxxxxxxx,102.427805337222)
Command: TEST_0401
Select BasePoint for Rectangle: Select opposite corner:
bp: (124.336509462923,154.833593887077,0)
cp: (46.6810247156286,61.5013804661373,0)
minPt: (46.6810247156286,61.5013804661373)
maxPt: (124.336509462923,154.833593887077)

 

 

 

 

I hope that is something like you are looking for.

 

Regards,

 

 

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 17 of 17
Ed.Jobe
in reply to: kdub_nz

Thanks @kdub_nz . That's where I was heading. He was just manually asking for 2 points. Not only does using prompt selection feel more like common user experience, but it provides structure for handling the results.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report