473,216 Members | 1,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

Pulling dimension from a part in SolidWorks Macro

5 Nibble
Hi Everyone, I am very new at VB and with macro in SolidWorks. As I have stated in the title, I am trying to find a way to pull the radius of the bottle base (a part) and populated it in the user form or have it assigned to a variable so I can use it in calculation.

User Form V1.PNG shows the user form that I will be using to collect necessary data from the user. Currently, the user will have to manually measure the radius of the bottle in SolidWorks and input it in the userform. However, I would like to make it so that the user will not have to measure the radius, instead have the macro pull that data on its own and assign it to a variable so I can use it for calculation. I am really not sure, how to implement this or if there's a better method to go about this.

I apologize for the long writing but I wanted to make sure everyone understand what I am trying to get the macro to do. Thank you in advance. I really appreciate it.
Attached Images
File Type: png User Form V1.PNG (11.7 KB, 155 views)
File Type: jpg User Form Code.jpg (105.4 KB, 141 views)
Jul 8 '20 #1
6 2878
272 256MB
Combobox1 has "BASE 1" to "BASE 6" set, but Change() has no options other than "Bottele 1" to "Bottle 6".
If you don't unify them either, the program does nothing.
Jul 8 '20 #2
5 Nibble
Hi, yes thank you for pointing that out, that was my mistake. Also thank you, your code helped me last time. Could you help me on how I could go about pulling the dimension from the bottle. Please let me know if you need more information from me.
Jul 8 '20 #3
272 256MB
Use the "text" property to display the value in the textbox.
Use the "value" property to reference the value in the textbox.
Expand|Select|Wrap|Line Numbers
  1. Public value As Double
  3. Private Sub UserForm_Initialize()
  4.     With ComboBox1
  5.         .AddItem "Bottle 1"
  6.         .AddItem "Bottle 2"
  7.         .AddItem "Bottle 3"
  8.         .AddItem "Bottle 4"
  9.         .AddItem "Bottle 5"
  10.         .AddItem "Bottle 6"
  11.     End With
  12. End Sub
  14. Private Sub ComboBox1_Change()
  15.     Select Case ComboBox1.List(ComboBox1.ListIndex)
  16.         Case "Bottle 1"
  17.             value = 1.1
  18.         Case "Bottle 2"
  19.             value = 1.2
  20.         Case "Bottle 3"
  21.             value = 1.3
  22.         Case "Bottle 4"
  23.             value = 1.4
  24.         Case "Bottle 5"
  25.             value = 1.5
  26.         Case "Bottle 6"
  27.             value = 1.6
  28.     End Select
  30. End Sub
  32. Private Sub CalculateButton_Click()
  33.     AngleTextBox.Text = Math.Atn((CDate(RadiusTextBox.value) / CDate(HightTextBox.value)) * (180# / PI()) + value
  34. End Sub
  36. Function PI()
  37.     PI = 4# * Atn(1#)
  38. End Function
Jul 9 '20 #4
5 Nibble
So this would allow for me to reference the value from the part? How would the code know get which part of its body, in solidworks, I am wanting the dimension of? Would this not just grab the code from the text box?
Jul 9 '20 #5
272 256MB
I don't know how to get the data of SolidWorks.
You can think of it. And assign it as RadiusTextBox.text=XXXX and HightTextBox.text=XXXX in Combobox1_change() Fanction.
I just fixed a mistake in your code.
Jul 9 '20 #6
272 256MB
If the bottle geometry data is stored in the table and you want to retrieve it from the table, issue a query (Select statement).
Jul 9 '20 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a...
by: Steve Jorgensen | last post by:
Hi all, I'm working on the schema for a database that must represent data about stock & bond funds over time. My connundrum is that, for any of several dimension fields, including the fund name...
by: Alexander Ulyanov | last post by:
Hi all. Is it possible to pass the whole blocks of code (possibly including " and ,) as macro parameters? I want to do something like: MACRO(FOO, "Foo", "return "Foobar";", "foo();...
by: Garry Freemyer | last post by:
I'm trying to convert this macro to a c# function but I have a big problem. It's on the LEFT side of an assignment statement and I am extremely flustered over this one because I'm a little rusty...
by: junky_fellow | last post by:
Hi, Are there any issues if I define a macro as follows: #define MY_MACRO(a,b); my_function((a),(b)); and calling this macro as follows, MY_MACRO(a,b);
by: Jimbo | last post by:
Im trying to design my time dimension and need to add a field to handle null dates in the fact. So if at the time of ETL the date isnt known, referential integrity will be preserved. Kimball...
by: John Torres | last post by:
I am trying to create a combo box search on the form with the Part Number but for some reason itís pulling the Part Number Tableís Primary Key. Canít figure out why. Any ideas where to start? FYI-...
by: kesterson.al | last post by:
solidworks crack http://cracks.00bp.com F R E E
by: hollierfloanuu | last post by:
solidworks 2008 crack http://cracks.00bp.com F R E E
by: mahendra dubey | last post by:
Hi there I have c# application that runs on both 32bit and 64 bit machine. In my app, I want to check whether solidworks is installed on computer or not. Can we check it ,by reading registry keys(for...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.