How to Discern Equations Syntax

Use this space to ask how to do whatever you're trying to use SolidWorks to do.
jmongi
Posts: 101
Joined: Wed Mar 24, 2021 1:25 pm
Answers: 0
x 15
x 81

How to Discern Equations Syntax

Unread post by jmongi »

I've tried to understand the help file and examples and I must be dense. Anyone got a good reference on equation syntax?

Here's the basic concept for reference:

I have 4 beams, two are set by other parts and two are equally spaced between the two set beams. So, I set a global variable equal to the space between the two beams and want to use that to set the equal spacing.

But every time I try to create my equation it errors on syntax.

= 'InnerSpacing' / 3

I must be missing something supremely basic, but, there it is.
Designated Pot-Stirrer
User avatar
zwei
Posts: 701
Joined: Mon Mar 15, 2021 9:17 pm
Answers: 18
Location: Malaysia
x 185
x 599

Re: How to Discern Equations Syntax

Unread post by zwei »

I believe it is supposed to be double quote?

Eg: ="LoremIpsum"/3
image.png
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
User avatar
gupta9665
Posts: 361
Joined: Thu Mar 11, 2021 10:20 am
Answers: 20
Location: India
x 387
x 417

Re: How to Discern Equations Syntax

Unread post by gupta9665 »

How are you creating your equations? Can you share picture of equation manager or the model file itself?
Deepak Gupta
SOLIDWORKS Consultant/Blogger
jmongi
Posts: 101
Joined: Wed Mar 24, 2021 1:25 pm
Answers: 0
x 15
x 81

Re: How to Discern Equations Syntax

Unread post by jmongi »

Well, maybe I don't need syntax after all but a program that isn't schizophrenic!
So, I went to create a screen pic per the last post request and opened the equation manager. I decided to also check on Zhen-Wei Tee's suggestion about the double quote vs single quote.

I am looking at the equation and mentally checking off that it's a double quote when I notice that the "Evaluates to" column has the correct value in it. Strange...I click on the "Value / Equation" field to see if I get an error after selecting the green check mark and voila! No error now. Nothing changed, I didn't type anything new I just saved when it asked me if I wanted to despite the "rebuild error" from the "bad" equation. The save happened roughly twenty minutes ago before I took a phone call and came back to this thread.

Any thoughts on what is going on? I am 99.9% sure that I had closed and reopened the equation editor many times in trying to sort this out. For the sake of finality the following syntax worked fine in the end.

= "InnerSpacing" / 3

I'd still like to have some idea, even if hypothetical, about why it wouldn't work and now it does.
Designated Pot-Stirrer
User avatar
HerrTick
Posts: 207
Joined: Fri Mar 19, 2021 10:41 am
Answers: 1
x 32
x 310

Re: How to Discern Equations Syntax

Unread post by HerrTick »

If you can pick a dimension or equation right by mouse, do that.
User avatar
the_h4mmer
Posts: 136
Joined: Mon Jan 31, 2022 6:49 am
Answers: 1
x 106
x 80

Re: How to Discern Equations Syntax

Unread post by the_h4mmer »

What version of Solidworks are you running?

On 2018, 2020, and 2021, when I type ` = ` then start typing the name of a Global Variable, there is usually a dropout menu option to click on the variable, and I double click that which auto-fills the rest of the text, including the quotes. As @Zhen-Wei Tee mentioned, the error may have been due to the single vs double quotes.

As far as the rebuild error, perhaps the software corrected the syntax error when saving? Not sure how or what could have cleared that, but an interesting series of events. ¯\_(ツ)_/¯
User avatar
JuTu
Posts: 81
Joined: Thu Mar 25, 2021 4:00 am
Answers: 1
Location: Finland
x 56
x 35

Re: How to Discern Equations Syntax

Unread post by JuTu »

jmongi wrote: Fri Mar 18, 2022 11:24 am I've tried to understand the help file and examples and I must be dense. Anyone got a good reference on equation syntax?

Here's the basic concept for reference:

I have 4 beams, two are set by other parts and two are equally spaced between the two set beams. So, I set a global variable equal to the space between the two beams and want to use that to set the equal spacing.

But every time I try to create my equation it errors on syntax.

= 'InnerSpacing' / 3

I must be missing something supremely basic, but, there it is.
Wait! Hold on! Uhm...

My co-worker had exactly the same problems couple of days ago.

Do you use other programs that use VBA? Issue seems to relate VBA version somehow, since after completely uninstalling and installing SW (2020 SP5.0 btw) equation manager threw him the same syntax error. Then he tried installing all the different versions of VBA that were delivered with our SW installation package. He uses VBA with MS Office and some other applications also implement it.
Sincerely,
JuTu
__________________
Lentäjä on ulkona ja lukossa.
jmongi
Posts: 101
Joined: Wed Mar 24, 2021 1:25 pm
Answers: 0
x 15
x 81

Re: How to Discern Equations Syntax

Unread post by jmongi »

1. Yes I do use various versions of VBA with Office.
2. I don't think the rebuild/save corrected anything from what was being displayed to me.
3. I only got the drop down selection after = functionality when doing very specific order of tasks. Just using = in the dimensioning portion of the initial mate creation did not work.
4. Version specific bugs aside, I suspect it was a data update issue of some type. Meaning, the sync between the window popup fields holding the text string of the equation and the backend equation solver database may have been broken in some way that was fixed when SW "rebuilt" after the error. After the "fix" it realized that the text in my popup window field had been changed, synced the change and then realized the change could be resolved by the solver.

That's all speculation on my part, but that's what it appears to be. I've run into similar type of error where SW decides a fully constrained component in an assembly is not fully constrained due to an unrelated edit and the only way to re "solve" the mate is to close the assembly and reopen it.
Designated Pot-Stirrer
Post Reply