Macro for Toggling Transparency of Components

Library for macros
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Macro for Toggling Transparency of Components

Unread post by Slasher »

Hello forum,

My 1st post here! looking for a macro which I think might be helpful for all actually.

So you know how you can use tab and shift-tab to hide & unhide hovered components; love that feature, super convenient, right?

Can something like that be done but for transparency (basically a toggle)? Hover would be best, but I assume it won't be as easy? How about pre-selecting the component, press a key (assigned to the said macro), make the part transparent, click again and make it opaque? I searched for such a macro a bit, no luck.


Thanks in advance!
Vahid
by JSculley » Wed Oct 25, 2023 10:44 am
Slasher wrote: Mon Oct 23, 2023 6:20 pm Hello forum,

My 1st post here! looking for a macro which I think might be helpful for all actually.

So you know how you can use tab and shift-tab to hide & unhide hovered components; love that feature, super convenient, right?

Can something like that be done but for transparency (basically a toggle)? Hover would be best, but I assume it won't be as easy? How about pre-selecting the component, press a key (assigned to the said macro), make the part transparent, click again and make it opaque? I searched for such a macro a bit, no luck.


Thanks in advance!
Vahid
This is a one-liner macro. You can easily assign it to a hot key. Pre-selection of one or more components is required.

Code: Select all

Dim swApp As Object
Sub main()
    Set swApp = Application.SldWorks
    swApp.RunCommand swCommands_e.swCommands_ChangeTransparency, ""
End Sub
Go to full post
User avatar
josh
Posts: 295
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 508

Re: Macro for Toggling Transparency of Components

Unread post by josh »

There's no need for a macro. Toggle transparency is already a button in the UI. You can map the command to a shortcut key.
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Re: Macro for Toggling Transparency of Components

Unread post by Slasher »

Hi Josh,

I'm using 2020 and transparency toggle or anything like that won't shop up in the commands (under keyboard tab in customize menu) when you search for it.
MattW
Posts: 60
Joined: Wed May 12, 2021 12:39 pm
Answers: 2
x 5
x 33

Re: Macro for Toggling Transparency of Components

Unread post by MattW »

I think this shows up by default when you click on a part
image.png
User avatar
SPerman
Posts: 2056
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2227
x 1878
Contact:

Re: Macro for Toggling Transparency of Components

Unread post by SPerman »

According to the swamp the answer is no. It is an old thread, but has replies from the last few months.

https://r1132100503382-eu1-3dswym.3dexp ... 9ijKAr-pKg

If you are trying to write a macro, I think this is the call you are looking for.

https://help.solidworks.com/2020/englis ... Redirect=1
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Re: Macro for Toggling Transparency of Components

Unread post by Slasher »

MattW wrote: Tue Oct 24, 2023 4:21 pm I think this shows up by default when you click on a part
image.png

Yeah I am aware of that, but I'm trying to avoid the extra clicks. I like to be able to assign a key to it and toggle quickly between opaque and transparent, solidworks currently doesn't allow that, hence my inquiry about a macro that can do that.
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Re: Macro for Toggling Transparency of Components

Unread post by Slasher »

SPerman wrote: Tue Oct 24, 2023 4:32 pm According to the swamp the answer is no. It is an old thread, but has replies from the last few months.

https://r1132100503382-eu1-3dswym.3dexp ... 9ijKAr-pKg

If you are trying to write a macro, I think this is the call you are looking for.

https://help.solidworks.com/2020/englis ... Redirect=1
Thanks for the link...for a second I thought I'm missing something after @josh comment, but yeah definitely you can't assign a hotkey to this command without a macro.

As for the api link, unfortunately I am not knowledgeable enough to write the macro :(
User avatar
SPerman
Posts: 2056
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2227
x 1878
Contact:

Re: Macro for Toggling Transparency of Components

Unread post by SPerman »

Slasher wrote: Tue Oct 24, 2023 7:13 pm Thanks for the link...for a second I thought I'm missing something after @josh comment, but yeah definitely you can't assign a hotkey to this command without a macro.
I went through the settings in SW and couldn't find it either.
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
User avatar
JSculley
Posts: 648
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 881

Re: Macro for Toggling Transparency of Components

Unread post by JSculley »

SPerman wrote: Wed Oct 25, 2023 7:46 am I went through the settings in SW and couldn't find it either.
SPR184416 -- Unable to assign a hot key to "Change transparency" (short cut key quick )
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Re: Macro for Toggling Transparency of Components

Unread post by Slasher »

Found this thread from eng-tips which is about same request; but the link referenced there to the macro is dead

https://www.eng-tips.com/viewthread.cfm?qid=140985
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Re: Macro for Toggling Transparency of Components

Unread post by Slasher »

JSculley wrote: Wed Oct 25, 2023 10:23 am SPR184416 -- Unable to assign a hot key to "Change transparency" (short cut key quick )
Hello JSculley, where can I see a list of these SPRs. Do you have a link?
User avatar
SPerman
Posts: 2056
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2227
x 1878
Contact:

Re: Macro for Toggling Transparency of Components

Unread post by SPerman »

This will take you to the knowledge base. From there you can search for that SPR.

https://support.3ds.com/knowledge-base/
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
User avatar
SPerman
Posts: 2056
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2227
x 1878
Contact:

Re: Macro for Toggling Transparency of Components

Unread post by SPerman »

Based on that link, it is possible the creator of these forums could be the author of that macro.

@matt
image.png
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
User avatar
JSculley
Posts: 648
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 881

Re: Macro for Toggling Transparency of Components

Unread post by JSculley »

Slasher wrote: Mon Oct 23, 2023 6:20 pm Hello forum,

My 1st post here! looking for a macro which I think might be helpful for all actually.

So you know how you can use tab and shift-tab to hide & unhide hovered components; love that feature, super convenient, right?

Can something like that be done but for transparency (basically a toggle)? Hover would be best, but I assume it won't be as easy? How about pre-selecting the component, press a key (assigned to the said macro), make the part transparent, click again and make it opaque? I searched for such a macro a bit, no luck.


Thanks in advance!
Vahid
This is a one-liner macro. You can easily assign it to a hot key. Pre-selection of one or more components is required.

Code: Select all

Dim swApp As Object
Sub main()
    Set swApp = Application.SldWorks
    swApp.RunCommand swCommands_e.swCommands_ChangeTransparency, ""
End Sub
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Re: Macro for Toggling Transparency of Components

Unread post by Slasher »

SPerman wrote: Wed Oct 25, 2023 10:37 am This will take you to the knowledge base. From there you can search for that SPR.

https://support.3ds.com/knowledge-base/
Nothing will show up when I look up this SPR:
image.png
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Re: Macro for Toggling Transparency of Components

Unread post by Slasher »

JSculley wrote: Wed Oct 25, 2023 10:44 am This is a one-liner macro. You can easily assign it to a hot key. Pre-selection of one or more components is required.

Code: Select all

Dim swApp As Object
Sub main()
    Set swApp = Application.SldWorks
    swApp.RunCommand swCommands_e.swCommands_ChangeTransparency, ""
End Sub
Thanks! I will give it a try, hopefully SOLIDWORKS add it with the hover functionality!
User avatar
matt
Posts: 1590
Joined: Mon Mar 08, 2021 11:34 am
Answers: 19
Location: Virginia
x 1219
x 2378
Contact:

Re: Macro for Toggling Transparency of Components

Unread post by matt »

SPerman wrote: Wed Oct 25, 2023 10:41 am Based on that link, it is possible the creator of these forums could be the author of that macro.

@matt

image.png
That's a really REALLY old link. 20 years old or more. I think that's an address I had when I lived in Rochester. REALLY old. 20+ years.
User avatar
AlexLachance
Posts: 2195
Joined: Thu Mar 11, 2021 8:14 am
Answers: 17
Location: Quebec
x 2382
x 2021

Re: Macro for Toggling Transparency of Components

Unread post by AlexLachance »

matt wrote: Wed Oct 25, 2023 12:54 pm That's a really REALLY old link. 20 years old or more. I think that's an address I had when I lived in Rochester. REALLY old. 20+ years.
Verizon.net as your first website host Matt... <()> :lol:
Slasher
Posts: 43
Joined: Mon Oct 23, 2023 6:13 pm
Answers: 0
x 40
x 20

Re: Macro for Toggling Transparency of Components

Unread post by Slasher »

matt wrote: Wed Oct 25, 2023 12:54 pm That's a really REALLY old link. 20 years old or more. I think that's an address I had when I lived in Rochester. REALLY old. 20+ years.
Can you dig up that macro for me please? Just kidding.
User avatar
SPerman
Posts: 2056
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2227
x 1878
Contact:

Re: Macro for Toggling Transparency of Components

Unread post by SPerman »

AlexLachance wrote: Wed Oct 25, 2023 1:12 pm Verizon.net as your first website host Matt... <()> :lol:
At least it wasn't a MySpace page. :)
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
User avatar
matt
Posts: 1590
Joined: Mon Mar 08, 2021 11:34 am
Answers: 19
Location: Virginia
x 1219
x 2378
Contact:

Re: Macro for Toggling Transparency of Components

Unread post by matt »

AlexLachance wrote: Wed Oct 25, 2023 1:12 pm Verizon.net as your first website host Matt... <()> :lol:
They gave dialup customers FTP space. I had a website in 1995. I posted user group presentations. The whole format translated perfectly into blogs. This was back when Verizon was a regular phone company, before they became a wireless juggernaut.
Post Reply