Page 1 of 1

Macro for Toggling Transparency of Components

Posted: Mon Oct 23, 2023 6:20 pm
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

Re: Macro for Toggling Transparency of Components

Posted: Tue Oct 24, 2023 7:21 am
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.

Re: Macro for Toggling Transparency of Components

Posted: Tue Oct 24, 2023 3:49 pm
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.

Re: Macro for Toggling Transparency of Components

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

Re: Macro for Toggling Transparency of Components

Posted: Tue Oct 24, 2023 4:32 pm
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

Re: Macro for Toggling Transparency of Components

Posted: Tue Oct 24, 2023 6:41 pm
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.

Re: Macro for Toggling Transparency of Components

Posted: Tue Oct 24, 2023 7:13 pm
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 :(

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 7:46 am
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.

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 10:23 am
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 )

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 10:24 am
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

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 10:32 am
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?

Re: Macro for Toggling Transparency of Components

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

https://support.3ds.com/knowledge-base/

Re: Macro for Toggling Transparency of Components

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

@matt
image.png

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 10:44 am
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

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 11:45 am
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

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 11:46 am
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!

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 12:54 pm
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.

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 1:12 pm
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:

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 1:33 pm
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.

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 1:33 pm
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. :)

Re: Macro for Toggling Transparency of Components

Posted: Wed Oct 25, 2023 3:28 pm
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.