473,395 Members | 1,616 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,395 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, 158 views)
File Type: jpg User Form Code.jpg (105.4 KB, 144 views)
Jul 8 '20 #1
6 2891
SioSio
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
zaxper95
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
SioSio
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
  2.  
  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
  13.  
  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
  29.  
  30. End Sub
  31.  
  32. Private Sub CalculateButton_Click()
  33.     AngleTextBox.Text = Math.Atn((CDate(RadiusTextBox.value) / CDate(HightTextBox.value)) * (180# / PI()) + value
  34. End Sub
  35.  
  36. Function PI()
  37.     PI = 4# * Atn(1#)
  38. End Function
Jul 9 '20 #4
zaxper95
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
SioSio
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
SioSio
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

25
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...
9
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...
3
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();...
4
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...
8
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);
4
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...
3
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-...
0
by: kesterson.al | last post by:
solidworks crack http://cracks.00bp.com F R E E
0
by: hollierfloanuu | last post by:
solidworks 2008 crack http://cracks.00bp.com F R E E
2
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.