Macro problems

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

Reply to
bagarnx
Loading thread data ...

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

Reply to
Corey Scheich

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

Reply to
rocheey

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

Reply to
Wayne Tiffany

Thanks wayne I was totally confused by that reply I thought I was going crazy.

Corey

Reply to
Corey Scheich

Millenium bug strikes again :p

Reply to
rocheey

Seems google groups together conversations with the Same subject wether or not they are truely related. Can be quite confusing at times.

Corey

Reply to
Corey Scheich

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.

formatting link

Reply to
bagarnx

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

Reply to
Wayne Tiffany

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

Reply to
bagarnx

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

SwConstTypeLibrary

Reply to
Corey Scheich

Thanks, I tried your suggestion, but didn't get it to work. I emailed API-support, and got this response:

use of View.>ScaleDecimal:

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

Reply to
bagarnx

Thanks, I tried your suggestion, but didn't get it to work. I emailed API-support, and got this response:

use of View.>ScaleDecimal:

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

Reply to
bagarnx

Thanks, I tried your suggestion, but didn't get it to work. I emailed API-support, and got this response:

use of View.>ScaleDecimal:

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

Reply to
bagarnx

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

SwConstTypeLibrary!

message

swInputDimValOnCreate

Reply to
Corey Scheich

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.