I am trying to write some VBA that sets the "Component Display" of the assemblies and parts in an assembly to "Default Display". I was hoping to find a method in IComponent2, but am having no luck. Any advice is appreciated.
Thank You,
Search found 58 matches
- Wed Sep 18, 2024 8:39 pm
- Forum: API
- Topic: Assembly "Component Display" setting
- Replies: 0
- Views: 64
- Mon Sep 16, 2024 1:55 pm
- Forum: API
- Topic: How to determine if file is checked out?
- Replies: 1
- Views: 101
How to determine if file is checked out?
I have some code that successfully checks files out, saves them, checks them back in, or undoes checkout. What I can't get it to do is correctly report if a file is checked out. pdmFile.IsLocked always returns FALSE. Here's my code. Function IsCheckedOut(swApp As SldWorks.SldWorks, ByVal pdmVault, h...
- Tue Sep 10, 2024 6:16 pm
- Forum: API
- Topic: Editing Config Specific Props from BOM question
- Replies: 3
- Views: 164
Re: Editing Config Specific Props from BOM question
AlexB,
I'm opening the parts/assemblies as I'm going through a drawing BOM.
I managed to get my code working today, much like I described. Now, to move them to the vault and check them in and figure out how the PDM API...
Thank you for your offer of help. I might just take that you up on that.
I'm opening the parts/assemblies as I'm going through a drawing BOM.
I managed to get my code working today, much like I described. Now, to move them to the vault and check them in and figure out how the PDM API...
Thank you for your offer of help. I might just take that you up on that.
- Tue Sep 10, 2024 1:41 pm
- Forum: API
- Topic: Editing Config Specific Props from BOM question
- Replies: 3
- Views: 164
Editing Config Specific Props from BOM question
I'm writing a macro that will iterate through a BOM and will edit configuration specific properties of parts/assemblies in the BOM. To be clear, I want to edit the part/assembly files themselves. This is a big step beyond anything I have written before and have a question. I know how to traverse the...
- Mon Sep 09, 2024 2:59 pm
- Forum: API
- Topic: Need Help with EditBalloonProperties2
- Replies: 2
- Views: 181
Re: Need Help with EditBalloonProperties2
Thank You, Josh. "BoolStatus = swAnnot.Select3(False, Nothing)" did the trick.
- Mon Sep 09, 2024 10:02 am
- Forum: API
- Topic: Need Help with EditBalloonProperties2
- Replies: 2
- Views: 181
Need Help with EditBalloonProperties2
I'm writing a macro that iterates through a drawing and changes the style of BOM Balloons, but It errors with "Object or variable With block variable not set." Here's the relevent code: For j = 0 To UBound(swAnnotations) If DecodeAnnotType(swAnnot.GetType) = "swNote" Then Set swA...
- Fri Sep 06, 2024 7:55 pm
- Forum: API
- Topic: GetBalloonOptions() alternative?
- Replies: 0
- Views: 169
GetBalloonOptions() alternative?
I'm writing some code to manipulate BOM Balloons. Getting the following balloon properties is straightforward using "Get" statements. (Style, Size, UpperTextStyle, UpperText, LowerTextStyle, LowerText) But when it comes to getting the following properties (CustomSize, ShowQuantity, Quantit...
- Mon Aug 26, 2024 10:34 am
- Forum: API
- Topic: Google Drive and SWP files
- Replies: 0
- Views: 165
Google Drive and SWP files
I use Google Drive to share SolidWorks VBA macros between several machines at both work and home. I have found that macro SWP files that are added to Google Drive using the Windows interface (versus Google Drive in a browser window) are not synced. Have others experienced this issue?
- Mon Jul 08, 2024 7:56 pm
- Forum: API
- Topic: Macro won't run if...
- Replies: 5
- Views: 1262
Re: Macro won't run if...
I have figured out a lot about this issue. It's really not a macro/API issue at all because it affects other command buttons as well. Here we go. image.png There are 3 placed in the SW that I tried placing "new macro" buttons for various macros that I use. I also put a "measuring tool...
- Mon Jul 08, 2024 4:45 pm
- Forum: API
- Topic: Macro won't run if...
- Replies: 5
- Views: 1262
Re: Macro won't run if...
I'll share some videos soon, but in the meantime, I discovered that the behavior is different, depending on where the "new macro" button has been placed. If I put it on the Macro Toolbar, they seem to work on the first click. If I put the "new macro" button on the SW Window Title...
- Sat Jul 06, 2024 8:33 pm
- Forum: API
- Topic: Macro won't run if...
- Replies: 5
- Views: 1262
Macro won't run if...
If I run a macro while a cell in a drawing table is selected, nothing happens on the first click. If I click on the run icon a second time, it works fine. This bahavior happens when running a macro using a "new macro button" in the SW UI or when hitting the "run sub" play button ...
- Mon May 06, 2024 4:01 pm
- Forum: API
- Topic: Need to determine the value of DIM with attached GTOL
- Replies: 1
- Views: 856
Need to determine the value of DIM with attached GTOL
Given a selected GTOL frame, I need to determine the value of the DIM that the GTOL is attached to. It's easy enough to get the properties of a GTOL frame, and I can determine if it's attached to something, but getting the dimension itself is eluding me.
Thanks,
Thanks,
- Fri Nov 24, 2023 4:06 pm
- Forum: Macro Library
- Topic: Reset Light Sources
- Replies: 3
- Views: 1271
Re: Reset Light Sources
I wrote a similar one that deletes all lights and sets ambient to 1. Now all our parts that are the same material look the same.
- Thu Sep 28, 2023 9:38 am
- Forum: API
- Topic: Unable to Select and Unsuppress Center of Mass Feature
- Replies: 10
- Views: 1599
- Wed Sep 27, 2023 12:06 pm
- Forum: API
- Topic: Unable to Select and Unsuppress Center of Mass Feature
- Replies: 10
- Views: 1599
Re: Unable to Select and Unsuppress Center of Mass Feature
Don't use SelectByID2. SelectByID is what the macro recorder uses, but it's almost always the wrong thing to use when you're actually writing a macro. In this case, you already have a pointer to the Feature object, which has a Select2 method. But, in fact, since you already have a pointer to the Fe...
- Wed Sep 27, 2023 11:58 am
- Forum: API
- Topic: Unable to Select and Unsuppress Center of Mass Feature
- Replies: 10
- Views: 1599
- Wed Sep 27, 2023 8:52 am
- Forum: API
- Topic: Unable to Select and Unsuppress Center of Mass Feature
- Replies: 10
- Views: 1599
Unable to Select and Unsuppress Center of Mass Feature
When I insert a Center of Mass feature, it ends up being suppressed in all the unactive configurations even though I have the "Suppress Feature" setting unchecked in the properties for every configuration. So, I wrote a macro that will iterate through every configuration and every feature,...
- Wed Aug 23, 2023 11:39 am
- Forum: API
- Topic: Can't Delete Sheet Format AutoZones/Borders
- Replies: 0
- Views: 1254
Can't Delete Sheet Format AutoZones/Borders
My engineering group is having a problem where the SW Drawing AutoZones/Borders are being created 'by themselves' and often go undetected until later in our work flow, creating additional work to correct them. I want to modify one of our commonly used macros to also automatically delete these if the...
- Mon Aug 21, 2023 2:07 pm
- Forum: API
- Topic: Can't change Document Property
- Replies: 3
- Views: 833
Re: Can't change Document Property
Thank You, AlexB. I would have never caught that "typo" since I copied it verbatim from the SW API help pages. I can't figure out is what the proper syntax is for calls like this. I originally used the "BoolStatus = swApp.SetUserPreference..." form because that's what SW has in e...
- Mon Aug 21, 2023 12:57 pm
- Forum: API
- Topic: Can't change Document Property
- Replies: 3
- Views: 833
Can't change Document Property
Under Options->Document Properties->Drawing Sheets->Sheet format for new sheets, I am trying to change the settings using the methods documented here: https://help.solidworks.com/2021/english/api/swconst/DP_DrawingSheets.htm I have done this for other settings successfully, but just can't get it to ...
- Fri Aug 18, 2023 8:00 pm
- Forum: How To Questions
- Topic: How can I find if Mass Properties have been Overridden
- Replies: 2
- Views: 949
How can I find if Mass Properties have been Overridden
I have some assemblies and discovered that someone, a long time ago, overrode the mass properties of some of the parts. Other than going through every part and checking if the mass props have been overridden in every configuration, is there an easy way to identify them?
- Fri Aug 18, 2023 12:39 pm
- Forum: API
- Topic: Determine Configuration Name for each BOM QTY Column?
- Replies: 1
- Views: 721
Determine Configuration Name for each BOM QTY Column?
I have a BOM table for multiple configurations of an assembly. I would like to be able to get the name of the configuration for each QTY column. Is there a way to traverse the QTY columns and get the config name/number?
- Fri Aug 04, 2023 9:33 am
- Forum: 2D Drawings
- Topic: Row height on revision table
- Replies: 9
- Views: 3516
Re: Row height on revision table
This is likely linked to the fact that the Document Setting for Table Vertical Cell Padding is ignored by SolidWorks Drawings and has been for well over a decade. I just reported this bug (again).
- Wed Jul 19, 2023 9:33 pm
- Forum: API
- Topic: Macro in the PDM Vault
- Replies: 17
- Views: 3007
Re: Macro in the PDM Vault
What are you guys talking about an "add-in" instead of a macro?
- Thu Apr 06, 2023 2:35 pm
- Forum: API
- Topic: Material Search Add-In
- Replies: 22
- Views: 4279
Re: Material Search Add-In
Thank You!JSculley wrote: ↑Thu Apr 06, 2023 7:50 am The DLL and instructions on how to register it are now here:
https://github.com/jsculley/MaterialSea ... es/tag/0.4
- Wed Mar 29, 2023 11:51 pm
- Forum: API
- Topic: Material Search Add-In
- Replies: 22
- Views: 4279
- Tue Mar 28, 2023 8:58 am
- Forum: API
- Topic: Material Search Add-In
- Replies: 22
- Views: 4279
Re: Material Search Add-In
Because of my company's security policy, installing an MSI is difficult/impossible for apps that are not trusted. Is a standalone version possible?
- Sun Mar 26, 2023 12:16 pm
- Forum: API
- Topic: Solutions to Drawing Table Cell Padding Bug?
- Replies: 0
- Views: 1072
Solutions to Drawing Table Cell Padding Bug?
When creating new tables, cell padding often ends up being set to something different from what's specified in document properties. Often one or both of the padding values will be 0 (zero) instead of the non-zero value I specify (such as 0.02 in). I have tried writing VBA code to programatically se ...
- Mon Sep 12, 2022 10:45 am
- Forum: API
- Topic: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
- Replies: 6
- Views: 714
Re: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
Josh,
This helps. There is only one Ambient light and this function only works on Ambient lights. Specifying the light name did do the trick, though.
This helps. There is only one Ambient light and this function only works on Ambient lights. Specifying the light name did do the trick, though.
- Sun Sep 11, 2022 11:56 am
- Forum: API
- Topic: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
- Replies: 6
- Views: 714
Re: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
Here's a sample of code: Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim ModelDocExtension As ModelDocExtension Dim BoolStatus As Boolean Dim i As Integer Dim LightSourceCount As Integer Dim LightSourcename As String Dim LightSourceUserName As String D...
- Sat Sep 10, 2022 10:53 pm
- Forum: API
- Topic: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
- Replies: 6
- Views: 714
Re: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
What are you expecting to get from the function? It returns true or false. Do you understand what ByRef means? You have to pass variables into the function to receive all the values. That's how I'm using it and when I inspect the values after calling GetAmbienLight Properties, they are all zero or ...
- Sat Sep 10, 2022 7:58 pm
- Forum: API
- Topic: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
- Replies: 6
- Views: 714
Re: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
It must be the byref thingy. Guess I'll have to figure that out. Never rant into that that before.
- Sat Sep 10, 2022 6:42 pm
- Forum: API
- Topic: Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
- Replies: 6
- Views: 714
Doesn't work: GetAmbientLightProperties or SetAmbientLightProperties
Does anyone have any VBA examples that use GetAmbientLightProperties or SetAmbientLightProperties. I can't get anything but 0 or FALSE values from GettAmbientLightProperties. I also had to initialize/dim "Colour" to Long (instead of Integer as the API help defines it) to get it to complile...
- Fri Jun 03, 2022 8:07 am
- Forum: API
- Topic: How to make an duplicate array of the Selection Manager?
- Replies: 3
- Views: 632
Re: How to make an duplicate array of the Selection Manager?
Typically, you'll either want to do one of two things. 1. Keep all of the types of objects in an array the same type 2. Use 2 separate arrays of the same length and have array1 hold the objects and have array2 hold the object types. This way, if you know what type to treat your object as from array...
- Thu Jun 02, 2022 7:11 am
- Forum: API
- Topic: How to make an duplicate array of the Selection Manager?
- Replies: 3
- Views: 632
How to make an duplicate array of the Selection Manager?
I need to make an array of everything that the user has selected in the feature tree of an assembly file. The selected items an be planes, sketches, mates, parts, assemblies, etc. I made a copy of the selection manager's array in the form of a variant array, but I can't figure out how to operate on ...
- Wed May 18, 2022 8:29 pm
- Forum: API
- Topic: How does one use swCenterMarkConnectionLine_e Enumeration?
- Replies: 1
- Views: 839
How does one use swCenterMarkConnectionLine_e Enumeration?
I am working on some macros that gets and sets document properties for CenterMarks and gets and sets properties of CenterMarks themselves. I am trying to manipulate the settings around Circular Lines, Radial Lines, and Base Center Mark. I found the enumeration regarding this setting here: https://he...
- Mon May 09, 2022 11:52 pm
- Forum: API
- Topic: Custom design check - layers
- Replies: 7
- Views: 1725
Re: Custom design check - layers
Zhen-Wei Tee, That idea will work well for use because we use a unique revision table symbol (circle square) which is a headache since that's not a valid default symbol, so we have to manually change the symbol from one of the default options, but in this case, it will work in our favor since that s...
- Sat May 07, 2022 8:21 pm
- Forum: API
- Topic: How to identify the "parent" of a Centermark?
- Replies: 1
- Views: 490
How to identify the "parent" of a Centermark?
Is there a way, using VBA, to identify the geometry (arc, circle, hole, etc) that a CenterMark is attached to? If that's possible, I'd then want to be able to get properties of that geometry, such as diameter/radius.
Thank you
Thank you
- Sat May 07, 2022 7:48 pm
- Forum: API
- Topic: Custom design check - layers
- Replies: 7
- Views: 1725
Re: Custom design check - layers
Hammer, I recently ran into a limitation that I think will be a problem for you too. I don't think that there's a way to identify if a note is a revision symbol. I wanted to make a macro that finds and changes the color of all revision symbols that might be left over from previous revisions, but cou...
- Sat May 07, 2022 7:36 pm
- Forum: API
- Topic: select bom row
- Replies: 2
- Views: 655
Re: select bom row
You could add a column to the BOM table and put in an "X" for every item that is missing a balloon. The user could use this to mark their progress as they correct the missing balloons. Then, it would be simple for them to delete the column when they are done.
- Wed Mar 23, 2022 8:30 pm
- Forum: API
- Topic: I need help writing a keyboard event handler in VBA.
- Replies: 4
- Views: 1575
Re: I need help writing a keyboard event handler in VBA.
Nice! I'll check that out.gupta9665 wrote: ↑Mon Mar 21, 2022 2:23 am Sorry, I went the other way round. Check the macro codes here https://wellsr.com/vba/2017/excel/GetAs ... s-pressed/
- Sun Mar 20, 2022 3:23 pm
- Forum: API
- Topic: Property Tab Builder apply to both Global and Default config
- Replies: 6
- Views: 1514
Re: Property Tab Builder apply to both Global and Default config
If I'm not mistaken, Solidworks always checks first to see if a configuration property exists. If it does exists, then it would ignore the values in the Global and only use the Configuration property value. If it doesnt exist, then it would take the value from the Global. ResidentAtLarge, you are c...
- Sun Mar 20, 2022 3:10 pm
- Forum: API
- Topic: I need help writing a keyboard event handler in VBA.
- Replies: 4
- Views: 1575
Re: I need help writing a keyboard event handler in VBA.
SendKeys should be the key you looking for. Check codes by @Josh here https://r1132100503382-eu1-3dswym.3dexperience.3ds.com/#community:yUw32GbYTEqKdgY7-jbZPg/iquestion:cPZa4KkjSHKVJEaLiC692g Deepak, Thank you for your response. The Microsoft VBA reference says that SendKeys "Sends one or more...
- Sat Mar 19, 2022 3:30 pm
- Forum: API
- Topic: I need help writing a keyboard event handler in VBA.
- Replies: 4
- Views: 1575
I need help writing a keyboard event handler in VBA.
I need help writing a keyboard event handler in VBA. I'm trying to write a macro that will interact with the mouse and keyboard. I found a GREAT forum post where Josh Brady posted some code that works great with the mouse using GetMouse. In this example, if the mouse is clicked, a dialog comes up wi...
- Sat Mar 12, 2022 8:24 pm
- Forum: API
- Topic: Change Revision Symbol Border?
- Replies: 1
- Views: 490
Re: Change Revision Symbol Border?
I figured that that a Revision Symbol is really just a Balloon. I can insert the Revision Symbol using then change its format and border using
Code: Select all
swModel.InsertRevisionSymbol()
Code: Select all
SetTextFormat()
- Sat Mar 12, 2022 4:44 pm
- Forum: API
- Topic: Change Revision Symbol Border?
- Replies: 1
- Views: 490
Change Revision Symbol Border?
After inserting a Revision Symbol
How can I change its border. I don't see any method for that.
Thank You
Code: Select all
value = instance.InsertRevisionSymbol(X, Y)
Thank You
- Sat Mar 12, 2022 3:47 pm
- Forum: API
- Topic: Where do you get your MACRO ICONS
- Replies: 7
- Views: 5008
Re: Where do you get your MACRO ICONS
I did find this tip at https://www.javelin-tech.com/blog/2020/10/creating-macro-buttons-in-solidworks/ Extra: As you can see above, the Macro button has a generic icon image. If you want to apply a unique image for the Macro button, click “Choose Image” under “Appearance” in Step7. SOLIDWORKS provid...
- Sat Mar 12, 2022 11:24 am
- Forum: API
- Topic: Where do you get your MACRO ICONS
- Replies: 7
- Views: 5008
Where do you get your MACRO ICONS
I've developed a bunch of VBA macros that I depend on regularly. I have them in a custom toolbar, but they all have the same default SolidWorks icon. 1) Have you found a 'library' of useful icons that work well for this purpose? 2) Do you have a utility that makes it quick and easy to make your own ...
- Fri Mar 11, 2022 9:33 am
- Forum: API
- Topic: Need help iterating through Configurations... sort of
- Replies: 4
- Views: 878
- Fri Mar 11, 2022 9:31 am
- Forum: API
- Topic: Need help iterating through Configurations... sort of
- Replies: 4
- Views: 878
Re: Need help iterating through Configurations... sort of
The only thing that I have in my similar macro is that I am calling to show the configuration before I begin trying to hide the geometry. In your code, this can be the first line in your For Each loop. swModel.ShowConfiguration2 vConfigName Another thing to note, to speed things up you can check to...