Author Topic: Better way to write this  (Read 9313 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Better way to write this
« Reply #15 on: June 22, 2006, 05:56:51 PM »
got ya! yes, that could and should be condensed.  In the example Bryco posted, they moved those two lines to the bottom after the select case.  In the example I just posted for Mick, those are all separate subs, so my question was should they stay separate for memory use or be combined.

This can be a hard decision depending on implementation, if you are relying on random user input (i.e. they have a multiple choice like radio buttons or list box pick) a switch case with good ordering may be the only way to go but if you have buttons where the decision is 'direct', go directly to the sub without switch tests should be quicker.

As Greg said (is that THE Greg Blandin...coding!) and Bryco demonstrated you can still pick up some efficiency with some thought to 're-usable' code placement.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Better way to write this
« Reply #16 on: June 22, 2006, 06:03:24 PM »
is there a way to store a variable in the dwg (im thinking user??) to specify which ctb file should be saved with that dwg.  Then you could take out the random user input and go straight to the plot.  I know the ctb is stored in pagesetup, but as size changes, so does the ctb file.  Also, we get crap from vendors that use all kinds of colors, thus the vendor medium ctb file.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bob Wahr

  • Guest
Re: Better way to write this
« Reply #17 on: June 22, 2006, 06:06:48 PM »
I'm thinking named page setups although we've had this conversation and I know you don't want to use them.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Better way to write this
« Reply #18 on: June 23, 2006, 09:54:26 AM »
Bob, what I need is a way to find out whether or not a drawing was done by us or an outside vendor.  That drives which ctb file to use.  My biggest problem is people using the wrong ctb file.  And dont even try to batch plot
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Better way to write this
« Reply #19 on: June 23, 2006, 09:55:17 AM »
I'm thinking named page setups...
Could that name be extracted easily in my sub?  I need to test that
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

DaveW

  • Guest
Re: Better way to write this
« Reply #20 on: June 23, 2006, 10:28:05 AM »
Batch plt is a great utility.It took me a while to really get it down the way I wanted. Named pagesetups are big part of it. I use it to go to plt files, then use othercomputers that do not have ACAD to print them. I am going to follow this tread closely, as automating the process from VB sounds pretty good, but I do not know where to start either. :) When I see what you guys do, it amazes me that anything I do, coding wise, works at all.

Bob Wahr

  • Guest
Re: Better way to write this
« Reply #21 on: June 23, 2006, 10:59:59 AM »
Quote
Could that name be extracted easily in my sub?  I need to test that
Code: [Select]
Sub test()
Dim objPSet As AcadPlotConfiguration
Dim objPSets As AcadPlotConfigurations
Set objPSets = ThisDrawing.PlotConfigurations
For Each objPSet In objPSets
  Debug.Print objPSet.Name
Next objPSet
End Sub

Bob Wahr

  • Guest
Re: Better way to write this
« Reply #22 on: June 23, 2006, 12:10:15 PM »
Here's a function that is a part of a pagesetup creation/replacement DVB that I was doing.  I shelved it for some reason, maybe it was a time issue, I'm not sure, then forgot all about it until now.  Maybe it will help
Code: [Select]
Function SNA11x17()
Dim objPS As AcadPlotConfiguration
  Set objPS = ThisDrawing.PlotConfigurations.Add("SNA-AZTU-11x17", False)
  objPS.ConfigName = "\\SERVER2\SAVIN 4035 PCL 6"
  objPS.CanonicalMediaName = "Tabloid"
  objPS.CenterPlot = True
  objPS.PaperUnits = acInches
  objPS.PlotHidden = False
  objPS.PlotRotation = ac90degrees
  objPS.PlotType = acExtents
  objPS.PlotViewportBorders = False
  objPS.PlotViewportsFirst = True
  objPS.PlotWithLineweights = True
  objPS.PlotWithPlotStyles = True
  objPS.ScaleLineweights = False
  objPS.ShowPlotStyles = False
  objPS.StandardScale = acScaleToFit
  objPS.StyleSheet = "SNA-11X17.ctb"
  objPS.UseStandardScale = True
End Function
Now I got's to finish this thing.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Better way to write this
« Reply #23 on: June 23, 2006, 02:16:04 PM »
thats a lot like mine
Code: [Select]
Public Sub SetupAndPlot(ByRef Plotter As String, CTB As String, SIZE As String, PSCALE As String, ROT As String)
    Dim Layout As AcadLayout
    On Error GoTo Err_Control
    Set Layout = ThisDrawing.ActiveLayout
    Layout.RefreshPlotDeviceInfo
    Layout.ConfigName = Plotter    ' CALL PLOTTER
    Layout.PLOTTYPE = acExtents
    Layout.PlotRotation = ROT    ' CALL ROTATION
    Layout.StyleSheet = CTB    ' CALL CTB FILE
    Layout.PlotWithPlotStyles = True
    Layout.CanonicalMediaName = SIZE    ' CALL SIZE
    Layout.PaperUnits = acInches
    Layout.StandardScale = PSCALE    'CALL PSCALE
    Layout.ShowPlotStyles = False
    ThisDrawing.Plot.NumberOfCopies = 1
    Layout.CenterPlot = True
    Layout.ScaleLineweights = False
    Layout.RefreshPlotDeviceInfo
    ThisDrawing.Regen acAllViewports
    ZoomExtents
    Set Layout = Nothing
    ThisDrawing.Save
Exit_Here:
    Exit Sub

Err_Control:
    Select Case Err.Number
    Case "-2145320861"
        MsgBox "Unable to Save Drawing- " & Err.Description
    Case "-2145386493"
        MsgBox "Drawing is setup for Named Plot Styles." & (Chr(13)) & (Chr(13)) & "Run CONVERTPSTYLES command", vbCritical, "Change Plot Style"
    Case Else
        MsgBox "Unknown Error " & Err.Number
    End Select
End Sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bob Wahr

  • Guest
Re: Better way to write this
« Reply #24 on: June 23, 2006, 02:23:48 PM »
true dat.  Mine's alphabeticalized though ;P

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Better way to write this
« Reply #25 on: June 23, 2006, 07:45:41 PM »
I've been doing some set ups for metric and have once again failed completely to get the plotconfifs to work programmatically. It seems certain plotters wont behave. Some people have mentioned the order is important. I've switched stuff around all over the place to no avail. My code looks a lot like yours, I mean we are all setting the same things. But yours works. For a couple of years I have been using objectArx to open a template file and copy the plotconfigs which works perfectly but it's galling to not be able to do it the proper way.

Every setting is copied from a readout of a manually made plotconfig, so unless the plot origin requires umpteen decimal places they should all be kosher.
If you can see something wrong I'ld appreciate the tip.
Code: [Select]
Sub PcsMM()

    Dim pC As AcadPlotConfiguration
    Dim PCs As AcadPlotConfigurations
    Dim oLayout As AcadLayout
    Dim oLayouts As AcadLayouts
    Dim PlotOrig(1) As Double
    Dim Orig
   
    Set oLayouts = ThisDrawing.Layouts
    Set PCs = ThisDrawing.PlotConfigurations
    Set oLayout = ThisDrawing.PaperSpace.Layout
    PlotOrig(0) = 18.542: PlotOrig(1) = 12.192
   
    Set pC = PCs.Add("22x34final", False)
    With pC
        .PlotType = acExtents
        .CanonicalMediaName = "User1639"
        .CenterPlot = True
        .ConfigName = "\\DESIGNSERVER\HPDJ"
        .PlotOrigin = PlotOrig
        .PlotRotation = ac180degrees
        .StandardScale = ac1_1
    End With
    PcTyp pC
    oLayout.CopyFrom pC
   
    PlotOrig(0) = 19.01: PlotOrig(1) = 12.68
    Set pC = PCs.Add("22x34draft", False)
    With pC
        .PlotType = acLayout
        .CanonicalMediaName = "User1639"
        .ConfigName = "\\DESIGNSERVER\HPDRAFT"
        .PaperUnits = acMillimeters
        .PlotOrigin = PlotOrig
        .PlotRotation = ac180degrees
        .StandardScale = ac1_1
    End With
    PcTyp pC
    oLayout.CopyFrom pC
     
     

    PlotOrig(0) = 1.31: PlotOrig(1) = 4.48
    Set pC = PCs.Add("11x17half", False)
    With pC
       
        .PlotType = acExtents
        .CenterPlot = True
        .ConfigName = "\\designserver\KONICA"
        .PaperUnits = acMillimeters
        .PlotOrigin = PlotOrig
        .PlotRotation = ac270degrees
        .StandardScale = ac1_2
        '.CanonicalMediaName = "User288"
        .CanonicalMediaName = "Tabloid"
    End With
    PcTyp pC
 
     

'ModelSpace

    Set oLayout = ThisDrawing.ModelSpace.Layout
   
    Set pC = PCs.Add("22x34-model", True)
    With pC
        .ConfigName = "\\DESIGNSERVER\HPDJ"
        .StandardScale = ac1_1
        .CanonicalMediaName = "User1639"
        .PlotType = acExtents
        .PlotRotation = ac180degrees
    End With
    PCAdds pC

   
    Set pC = PCs.Add("22x34draft-model", True)
    With pC
        .ConfigName = "\\DESIGNSERVER\HPDRAFT"
        .StandardScale = ac1_1
        .CanonicalMediaName = "User1639"
        .PlotType = acExtents
        .PlotRotation = ac180degrees
    End With
    PcTyp pC

   
    Set pC = PCs.Add("11x17-model", True)
    Orig = ThisDrawing.GetVariable("Viewctr")
    PlotOrig(0) = Orig(0): PlotOrig(1) = Orig(1)
    With pC
        .ConfigName = "\\designserver\KONICA"
        .StandardScale = acScaleToFit
        '.SetCustomScale 1, 1
        .CanonicalMediaName = "Tabloid"
        '.PlotType = acExtents
        .CenterPlot = True
        .PlotOrigin = PlotOrig
        .PlotRotation = ac270degrees
    End With
    PcTyp pC
    oLayout.CopyFrom pC

'Pc.RefreshPlotDeviceInfo
ThisDrawing.Regen 0

End Sub
Function PcTyp(pC As AcadPlotConfiguration)

    With pC
        .PaperUnits = acMillimeters
        .PlotHidden = False
        .PlotViewportBorders = False
        .PlotViewportsFirst = True
        .PlotWithLineweights = True
        .PlotWithPlotStyles = True
        .StyleSheet = "Lexington Standard.ctb"
        .UseStandardScale = True
    End With
   
   
End Function

I'm also not sure of the logic of  using extents rather than layout. But that didn't work either.
« Last Edit: June 23, 2006, 07:48:56 PM by Bryco »

Bob Wahr

  • Guest
Re: Better way to write this
« Reply #26 on: June 23, 2006, 07:55:12 PM »
Bryco, at a quick glance, I don't see anything.  I'll look some more but not until Monday.

DaveW

  • Guest
Re: Better way to write this
« Reply #27 on: June 23, 2006, 09:02:36 PM »
Bryco,

I can't help you wiith that code, but if your problem is not there, then it won't matter.

Please do not forget to do the basics to remove all other outside variables and try to narrow it down while stepping through it. If it is failing, you should see that in design time. Something "should" give you a clue.

I would try a virgin machine and remove the call to a network printer and add a dedicated one on LPT1 instead and see if that works. I would not believe the order issue. That "should" not matter.

I can do some testing for you on a couple of diffent networks if you would like. Just let me know what info you need and make a arx, dll or dvb for 2002 and I would be more than happy to test anything I can for you. I have both, a dedicated canon on its own ip and shared out plotters.

Also, I see you have hp design jet in there. I remember having many issues with those old boxes, forget what they are called, that take the cat5 cable and turn it into a parallel port. You could have a faulty cable somewhere too, stc. Best to get your coded tested other places if it really being that bad.

Good luck

You can email or call me if you want a tester.

david@smartlister dot com
<phone number removed by MP>
« Last Edit: June 26, 2006, 12:35:44 PM by MP »