Macro problems

Discussion in 'SolidWorks' started by bagarnx, Aug 26, 2004.

  1. bagarnx

    bagarnx Guest

    Hi.

    Can anybody tell me why the following command doesn't work?

    'swApp.SetUserPreferenceToggle swInputDimValOnCreate, False'

    It's supposed to inactivate the Tools - Options - System options -
    Input Dimension Value

    But nothing at all happens.
    No errors are reported either.

    Thanks!
    /Anders
     
    bagarnx, Aug 26, 2004
    #1
  2. the apostrophy before the line makes it into a note line so VBA skips over
    it
    it should look like this. You also have to reference SwConstTypeLibrary so
    that swInputDimValOnCreate has a value assigned to it. And ofcourse you
    have to attach to SW itself.

    Sub Main ()

    Dim swApp as sldworks.sldworks

    'Attach to Solidworks
    Set swApp = Application.SldWorks

    'Set your user preference if you RMB over swInputDimValOnCreate
    'it should have a value of 10
    swApp.SetUserPreferenceToggle swInputDimValOnCreate, False

    End Sub
     
    Corey Scheich, Aug 26, 2004
    #2
  3. bagarnx

    rocheey Guest

    All of this was fine until I had to take my laptop in to be serviced
    Well, you didnt describe "dont work" specifically enough, but if they
    are actual CODE errors that are being mysteriously generated when the
    program is run, you may have to reload your Sldworks.tlb reference.
    Ive gotten these arrors before after a "fresh" major upgrade on
    existing programs, or sometimes when running multiple versions on SWX
    on the same O/S.

    Just clicking "Tools", "References" and double checking the path in
    not enough, I find I may have to BROWSE back to the same path
    specified and re-select the .tlb
     
    rocheey, Aug 27, 2004
    #3
  4. Not sure where you found this, but the original post you copied below was in
    Dec 2001 by Lee. There have been recent additions, with Corey's reply just
    yesterday. Was that the intended message for the reply?

    WT
     
    Wayne Tiffany, Aug 27, 2004
    #4
  5. Thanks wayne I was totally confused by that reply I thought I was going
    crazy.

    Corey
     
    Corey Scheich, Aug 27, 2004
    #5
  6. bagarnx

    rocheey Guest

    Not sure where you found this, but the original post you copied below was
    Millenium bug strikes again :p
     
    rocheey, Aug 27, 2004
    #6
  7. Seems google groups together conversations with the Same subject wether or
    not they are truely related. Can be quite confusing at times.

    Corey
     
    Corey Scheich, Aug 27, 2004
    #7
  8. bagarnx

    bagarnx Guest

    Thank you, the problem was that I didn't reference SwConstTypeLibrary!

    But now I have a new problem;
    Changing the text in a note in a drawing.

    I got
    Note.SetText("The New Text")
    to work once, and copied only that line into the macro I was going to
    use.
    Then it didn't work, but by then I had already erased the original
    macro...

    Is the problem this time too that there is something I need to
    reference to, or what am I doing wrong?

    At the URL below someone has the same problem, but has recieved no
    answers.
    http://makeashorterlink.com/?C48362539
     
    bagarnx, Sep 3, 2004
    #8
  9. Go to the SW API help and lookup Note::SetText. The example there has the
    line "swNote.SetText sNoteText" (without the quotes) and so you may want to
    try comparing your code to the example to find a difference. Or send me a
    copy and I will look at it.

    WT
     
    Wayne Tiffany, Sep 3, 2004
    #9
  10. bagarnx

    bagarnx Guest

    I used the code in the example you referred to, and after a bit of
    modification it works quite well!

    Now I have a new problem;
    I'm trying to get the scale automatically from a drawing view.
    The scale can be displayed in either decimal och ratio.

    When using
    Skala = View.ScaleDecimal

    it works fine, but with
    Skala = View.ScaleRatio

    I get "Run-Time error '13' - Type Mismatch"


    Can someone help me?

    /Anders
     
    bagarnx, Sep 8, 2004
    #10
  11. If you look up Scale Ratio in the API help you will see that it needs to be
    passed to a variant array

    Dim Skala() as variant

    I assume you are using

    Dim Skala as Long
    or
    Dim Skala as String
    or even
    Dim Skala as Variant

    none of these three will work

    Corey
     
    Corey Scheich, Sep 8, 2004
    #11
  12. bagarnx

    bagarnx Guest

    Thanks, I tried your suggestion, but didn't get it to work.
    I emailed API-support, and got this response:
    The SW API help said nothing about using 'ScaleRatio(0)' and
    'ScaleRatio(1)', but when I used it it all worked.

    Just thought that someone might be interested.

    Anyway, thanks for your responses!
    /Anders
     
    bagarnx, Sep 9, 2004
    #12
  13. bagarnx

    bagarnx Guest

    Thanks, I tried your suggestion, but didn't get it to work.
    I emailed API-support, and got this response:
    The SW API help said nothing about using 'ScaleRatio(0)' and
    'ScaleRatio(1)', but when I used it it all worked.

    Just thought that someone might be interested.

    Anyway, thanks for your responses!
    /Anders
     
    bagarnx, Sep 9, 2004
    #13
  14. bagarnx

    bagarnx Guest

    Thanks, I tried your suggestion, but didn't get it to work.
    I emailed API-support, and got this response:
    The SW API help said nothing about using 'ScaleRatio(0)' and
    'ScaleRatio(1)', but when I used it it all worked.

    Just thought that someone might be interested.

    Anyway, thanks for your responses!
    /Anders
     
    bagarnx, Sep 9, 2004
    #14
  15. that is what must be meant by

    SafeArray containing an array of 2 doubles

    I didn't realize that they were saying that you needed to have two variables
    of type double in the array I thought that the return values were just type
    double

    Corey
     
    Corey Scheich, Sep 9, 2004
    #15
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.