r/MechanicalEngineering • • 3d ago

Using AI to create macros/scripts is powerful

Anyone else been using AI to create macros/scripts to automate your repetitive work?

We all know that macro/script recording and playback for programs such as solidworks and SAP can be used to automate tasks. Over the past few months I've found that vibe-coding custom macros is very effective. Wanted to see what other engineers are doing with this

51 Upvotes

61 comments sorted by

45

u/rhythm-weaver 3d ago

Yes. We’re forced to use Copilot and I don’t trust it to handle the big picture. I use it to build the blocks that I assemble into the big picture.

12

u/Pinkys_Revenge 3d ago

Any tips for getting copilot to work well?

I use Claude for personal stuff but I’m also forced to use copilot for work. I find copilot to be painfully bad in comparison.

10

u/Wilthywonka 3d ago

Get your company to give you copilot premium. You can use the high end models from anthropic

1

u/Pinkys_Revenge 3d ago

Wait… really!?! Holy shit. Thank you!!!

2

u/Wilthywonka 3d ago

Yep it's super nice. It all stays within the network, so you get to use claude without worrying about IP stuff

2

u/involutes Manufacturing | Product Development 2d ago

What do you mean by "it stays within the network"? 

I don't think it's local AI. Maybe I'm too paranoid but I think they are still harvesting your IP, they're just archiving it and keeping it separate from all the data harvested from consumer-level users that they use to train their new models. Eventually though, they have enough data from you and your competitors and everybody else in the world that not really such a thing as "intellectual property" anymore. 

It's not like any of these AI companies were respecting IP when they were torrenting massive amounts from Anna's Archive for their training data. 

But unless you're the owner of the company, I wouldn't worry too much about it. 

1

u/Wilthywonka 19h ago

Yeah I have no way of knowing for sure what is happening with our information. I just know that the copilot app is the only ai my company has approved because the information is not supposed to go outside of our org, as opposed to firing up claude on a browser and feeding it your drawings

1

u/involutes Manufacturing | Product Development 14h ago

I understand. It's a common policy. I just think companies are feeling a false sense of security with MS Copilot Pro or whatever they call their higher tier subscription.

1

u/SnowyFlam Mechanical Engineer 1d ago

We just got the premium version for all engineers, downside is that you cant run automation without extra permissions that they wont approve. Basically all we have is a glorified consultant that can read our company policies and write macros in excel.

1

u/eim1213 1d ago

Better than nothing! Sounds pretty useful to me

11

u/Fit_Opportunity_9728 3d ago

Copilot is so bad

1

u/EOSMetalAM 3d ago

Manually change the AI model to the highest option available, that helps a decent amount

1

u/Probably-Stable 2d ago

Yes copilot…tinker toys

1

u/rhythm-weaver 3d ago

The copilot in Excel is good

2

u/Pinkys_Revenge 3d ago

Good to know. I’ve only tried it with outlook so far, and it couldn’t even find emails I had received 20 minutes earlier.

1

u/CopperGenie R&D | Author | ISERG 3d ago

Well said. I trust genAI insofar as I can verify its output.

7

u/EndingPop 3d ago

I'm replacing some of our expensive software with free stuff Opus can make. If you're careful in how you scope/define the work and test it thoroughly it does a great job. I point it at "/grill-me" from Matt Pocock's skills (https://github.com/mattpocock/skills) and have it work through the issues with me.

2

u/Wilthywonka 3d ago

My company has been starting to do something similar. Opus can build specialized tools that are 90% as good as the ones on the market. I've been very impressed by it

1

u/big-mover 3d ago

Can you be more specific? What is the expensive software doing?

5

u/EndingPop 3d ago

My team is focused on FEA/CFD. We aren't rewriting Abaqus or ANSYS (yet? seems like a much bigger lift/risk), but I already built a topology optimizer and a process automation tool for DOEs/optimization and that's been very straight-forward. No GUI, and much more limited than the commercial tools, but meets our current needs and extending them as needs arise has been super fast. The tools leverage what's already in the literature and/or available in Python libraries, along with our cluster submission commands, so what actually gets built is basically just wrappers. They call the commercial FEA/CFD codes we already know inside and out and have lots of V&V already completed.

It helps that I used to work a companies that made tools like this, so I know the requirements and danger zones, but honestly Opus does a good job of identifying risks when rebuilding something that already exists. For example, it suggested hashing designs to enable restarts without rerunning designs and to ensure stale designs don't get accidentally reused when the project is changed.

Several of the CAE vendors tried to squeeze us really hard this year on price and in response we cut our substantial software budget by 15% and are rebuilding what we cut. We're now looking hard at open source for FEA/CFD and will likely end up extending the tool capabilities with AI to meet our specific needs. I keep telling my boss that we should convince legal to let us release those updates back into the public projects. If everyone did that it'd start dropping the cost for the commercial tools in a hurry. It's about the only solution to the active enshittification among CAE tools.

1

u/raztok 3d ago

automatically exporting dxf.... with 1 click 🤷🏻‍♀️

15

u/Pinkys_Revenge 3d ago edited 3d ago

I’ve found it’s very good at checking spreadsheets for errors (we have budgets that are huge spreadsheets and no one has the attention span to check them thuroughly, but Ai does a great job and often finds mistakes.

It’s also great at comparing docs to each-other. For example, we often have a pdf writeup about a project that can be 20+ pages long and an associated budget, Ai is great at spotting inconsistencies between the two.

It’s also great at writing the BS flowery language for emails you sometimes need for sales people or executives who don’t like the way engineers normally communicate.

6

u/ArbaAndDakarba 3d ago

Sure, but I've found much more value in building analytical calculators based on codes / standards. Claude is extremely adept at it.

2

u/wimax91 3d ago

Yeah I’ve used it to set my parameters for my parametric designs that have 200+ variables (like it pulls dimensions from online data sheets for components and changes the parameters to allow for mounting)

3

u/Accro15 3d ago

Use the AI to teach you about scripts until you're comfortable. Then use the AI to make scripts. Then you can review them with some confidence.

3

u/SystemicAM 3d ago

I did until I grew tired of AI bs and the ethical problems surrounding it, now I'm sworn off it. Happy to make scripts myself as I used to. If I'm not doing the work myself then I'd rather find other work to do.

7

u/nice_arrears 3d ago

if a macro touches released drawings i wanna explain every line in a design review

1

u/zhnki 3d ago

Why not just review the final drawing. You don’t need to understand every building block used to make it. Does it convey the correct information or not.

4

u/acomputer1 3d ago

How to you determine if the information is correct if you don't understand what's underneath it?

This is the fundamental problem with using gen AI, you can use it to build tools that can be validated, but if you're letting it control the entire workflow you have no way to validate that is doing what it claims to be doing or of its just generating a plausible looking output.

1

u/Probably-Stable 2d ago

I can appreciate what you’re saying and I don’t completely disagree, however I don’t think it’s much different than having an employee. We wouldn’t micromanage an employee in exactly the way something had to be done so long as the proper guard rails / goals were adhered to.

I think ai is shifting so much of the way we will work. Yes you can get ai slop easily but there has also been very impressive results.

There’s different ways it can be validated along the way too. Just food for thought. :)

1

u/acomputer1 2d ago

If I asked a junior colleague to do something for me I would not simply accept their work because the top level drawing looked basically correct. I wouldn't do that for a colleague senior to me either, that's not how you properly check and evaluate that work is correct.

I also wouldn't accept their work if they didn't have a properly documented process they had followed to arrive at the solution they're putting in front of me and couldn't explain why they'd made the choices they did. AI does not know why it made choices, because functionally speaking the instance you're talking to didn't make the choice, a copy of it which no longer exists made the choice and likely didn't document why.

Another key difference is that a decent employee can be trusted to have actually done what they say they did. If they made a spreadsheet to calculate some values, you can generally trust that they actually used that tool to arrive at the values they're using, and you can validate the tool works correctly.

You can ask an LLM to build and use a tool, and there's really no way you can actually trust them to do so. I run into this exact problem with them all the time, I ask them to complete a task in a specific way any they simply lie and produce work that looks like what I've asked for, but upon closer inspection is wrong because it simply generated a value that was a good statistical match, not a value drawn from the appropriate source.

Again, it's useful for building tools you can use that can be validated and confirmed to function correctly.

I just used it the other day to build me a macro that will build standard shaped but variably sized parts in Solidworks in VBA, something that would have taken me probably a day to get right before LLMs and now I got it done in an hour on the first try, including setting up the Solidworks templates and excel input sheets.

Then there's my boss who uses it to produce documentation for projects he's working on by feeding it all the related project documents, emails, meeting transcripts, etc., and describing what he wants the documentation produced to look like and it is essentially unusable because it simply lies to produce something it thinks sounds correct, but when closely reviewed is wrong in significant ways.

Doesn't stop him producing mountains of slop no one will read, though.

1

u/zhnki 3d ago

By being competent and reviewing what you deliver as an engineer. How the sausage gets made is rarely important.

2

u/acomputer1 3d ago

If the only thing you're reviewing is the final output that's not being competent.

1

u/SnowyFlam Mechanical Engineer 1d ago

Competent enought to get paid the big bucks. If the customer is happy, we are all happy. And by happy i mean delivering products that dont break down after a few years.

1

u/acomputer1 1d ago

If you're not adding any value then I wouldn't count on earning those big bucks much longer.

I can't speak to what your workflow looks like, but if you're really not reviewing any intermediate steps between defining the problem and rubber stamping the solution I would be concerned to be your customer.

1

u/SnowyFlam Mechanical Engineer 1d ago

value is defined by what the customer pays for. As long as im being paid, im adding value regardless of your opinions.

For example, a civil PE can be paid for rubber stamping a final print and plans. That doesnt mean he ever had any input or actually worked on the plans, that was performed by another team.

-1

u/zhnki 3d ago

Well, that’s like, your opinion, man.

I get it, process and methodology are important but the most important thing to a customer at the end of the day is whether the thing is gonna work or not. AI can help, not replace. The person is still ultimately responsible. Use AI as much or as little as you want but remember it still has to work.

1

u/SnowyFlam Mechanical Engineer 1d ago

I have a macros made just to do the drawing revision check, saves me time analyzing the output and communicating changes

5

u/Ghooble 3d ago

Agreed

2

u/zhnki 3d ago

I get what you’re saying, but you may not have a choice to do the work you want with that approach. Good luck.

6

u/SystemicAM 3d ago

I won't have the choice to do the work I want without it either. I didn't go into this field so I could be a chatbox operator. Thinking about getting a trade ticket or something. Anything that's vaguely technical and can't reasonably be bimbofied by AI tools.

2

u/Aggressive_Ad_507 3d ago

I vibe code excel. It's great to get widgets and light databases set up.

My biggest uses have been reviewing documents for ISO and pressure vessel authority compliance.

2

u/joap25 3d ago

Made an add-in to connect inventor to our ERP tool. Amazing

2

u/lazydictionary Materials Science | Manufacturing | Mod 3d ago

We used to use Access for the front end of some of our internal databases. Been using LLMs to spin up web apps which are faster and more versatile now instead.

2

u/buginmybeer24 3d ago

I've been doing it long before AI. The AI just makes it faster.

1

u/SnowyFlam Mechanical Engineer 1d ago

touche, i dabbled in this myself, but boy was it time consuming. Now with a bot I just have generate, I read through it all, tweak what I want, and then boom, less than an hour later I have a great tool

1

u/Probably-Stable 2d ago

Good success feeding Claude code 2d drawings and allowing it to drive inventor to create 3d models. Also its interfacing with Vault to quickly pull reference models etc. very impressive

1

u/Usual-Recognition-49 1d ago

Agree, and I'd go one step further: I don't fully trust my own read of the code either. So I check the result.

After a change I put the old PDF next to the new one and compare the dimensions. Every dimension that's gone or different needs a reason. On one part that went from 550 to 715 mm wide that meant going through 5 sheets. Boring, but it's the only way I'd sign it.

1

u/SimultaneousThought 3d ago

Yep, and quick custom apps too

1

u/PigSlam 3d ago

It's pretty powerful. I've been tinkering with some game development stuff on my own time, and I've essentially built a CAD vault database/data store with viewer for managing assets I've had AI agents build using Blender/Godot Game Engine. It's incredible what you can have with a little planning and guidance.

1

u/PigSlam 3d ago

Yeah

1

u/BenchPressingIssues 3d ago

Yeah. I had it create a VBA macro to plug data from a spreadsheet into word document templates and save copies with the proper name. 

1

u/TheBlack_Swordsman 3d ago

Yes. For FEA stuff. It's been very helpful. LS-DYNA, automation of 100s of bodies to generate contact properties and then automating their force results out into Excel and then automating their force outputs in graphs, etc.

Turned 60-80 hours of work now into 8-12.

1

u/thirty2skadoo 3d ago

I’m automating all the design release bullshit workflows. The workflow has a UI that a human audits - the code under it is deterministic. I’be just setup Fluent MCP and I’m going to start using that for sim setup and post processing. 

1

u/MyDogNamedRed 3d ago

We have inventor, I use chatgpt to build some Ilogic form tool that helps with repetitive modeling, drawing details routine, its pretty useful.

1

u/metarinka 3d ago

I'm going beyond that.

It finishes up data packages. Exports. Relinks files. Light pdm work, folder structuring and Rev control.

I also have lots of simple but repetitive parts. Like drill bits in different diameters. It will make a macro but also just kick out the entire package and run tests to verify

1

u/sergiogsr 3d ago

At first I tried to create new macros or VBA code with copilot... but quickly found out that you can create tools using html format. Its easier, more powerful and its all local and works without internet connection if needed. 

You create a local html file that can take a file in different formats if needed and:  Can process it based on the source file content.  Can compare several different files. You can interact with the source file using forms, combo boxes, controls and check boxes.  You can load databases so it uses them to process the source file. 

And of course, can get an output file with the processing complete. 

I have created several tools like this. It has helped me to create: 

  • calculators based on databases that update constantly. 
  • user friendly file converters for legacy systems. 
  • quality assurance system for quotations.
  • quotation analysis and automated bundled solutions assistant (based on statistics and compatible combinations and attibute databases)
  • automated comparisons for large databases. 

Average creation time for most of the tools is less than an hour with Copilot, but you need to have a structured process to define the flows and validation of the output. 

-1

u/Lunastarfire 3d ago

Using AI to vibecode is fine for random low effort, low complexity tasks but its like trusting your uncle who only rides a push bike but has watched a load of youtube vids of pit crews and now youre getting him to fix an F1 Car.

He might be gods gifts to mechanics, but more likely it will be done with very low efficiency, major critical elements will be missed, and since you never checked in on it once, you just got to trust it doesnt explode.

Personally, I use it more like an apprentice, I ask it to do things that are broken down enough for it to understand, that I can quickly skim through to ensure its doing what I think its doing and to be open to new approaches, but ultimately its my work at the end.

1

u/Probably-Stable 2d ago

Hmm I’ve had a different experience. Might I ask what models you’re using?

1

u/Lunastarfire 2d ago

Claude, gpt and copilot though in work, copilot since thats the one they pay for.

Dont get me wrong for very basic functions in coding its great but ive worked with mcode, dax, and vba for years.

The answers i get back often will try and do things that cant be done with that command, its imagined bits or what could be made dynamic is made statically.

But it also tries on the first request to use a brute force approach to folding the data or does the entirely opposite but missing critical elements that nuance for the data analysis which was clearly defined in the query.

The two things i have found it good for, returning syntax and adding comments on code blocks, its lovely for that.

But while ai is getting better I still spot errors if I blindly copy larger tasks, they may be minor but in engineering, one minor error may be completely ignorable or could royally mess up everything.