Maximize your Ansys Zemax

  • Simulation Consulting
  • Blogs
  • Simulation
  • Sort by type
  • Technologies
  • Ansys
Published on
2023-10-24
Written by
Olli Hakala

Top tips on how to maximize your Ansys Zemax with Custom User-Defined Features

Would you like to take the efficiency of your Ansys Zemax to the next level? Would you like to save yourself from doing the same task repeatedly? Ansys Zemax supports user-defined custom features that will be your new friend.

One of the key aspects of is its flexibility in allowing users to create custom features to extend the capabilities of the software. These custom features can help you overcome challenges, improve your efficiency, and maintain precision in your work. In this article, Olli Hakala introduces how to create custom features for collimating shapes. Collimating shapes are being used from camera lenses to illumination and from medical applications to precision welding.

For decades, Zemax has been a leading software in optical design. It is a powerful and versatile tool for any kind of optical systems with vast number of features and readily available objects to be used. Yet there are instances where you may find that certain features are missing or not quite aligning with your specific needs. In such cases, it’s time to consider harnessing the potential of user-defined custom features.

Here are the three symptoms when you should consider user-defined custom features:

1. When Zemax Objects Don’t Behave as Desired

Regardless of the extensive library of optical components in Ansys Zemax, you may encounter situations where a particular component doesn’t behave exactly as you want it to. This could be due to unique specifications or unconventional requirements in your project. Instead of settling for a compromise, a user defined function can be tailored can be tailored to meet your specific needs. It offers you the flexibility to create, modify, or fine-tune optical elements to suit your design, ensuring that your optical system behaves exactly as intended.

2. When You’re Stuck in a Loop of Repetitive Calculations

In many optical design projects, there is a need to perform calculations that span multiple software applications, often involving back-and-forth data transfers between Ansys Zemax and tools like Microsoft Excel. If you find yourself repeatedly crunching numbers or copying data between these platforms, it’s a clear sign that you could benefit from a UDF. By streamlining these calculations within Zemax, you not only save time but also minimize the risk of errors associated with data transfer.

3. When Design Workarounds Become Routine

Sometimes, innovative optical designs demand unconventional approaches. You may find yourself repeatedly implementing workarounds to achieve your desired outcomes. While creativity is essential in optics, constantly resorting to workarounds can lead to inefficiencies and convoluted designs. With a user-defined custom feature, you can formalize these workarounds into standardized, efficient processes within your Zemax. This not only simplifies your workflow but also ensures consistency and quality across your projects.

How to Get Started with User-Defined Custom Features in Zemax

You might be thinking now, that doesn’t this require more than a bit of programming skills? Yes. There can be no way around the programming phase, but it is not the most important part, nor the most difficult part. The difficult part is to recognize the need (which you already might have done!) and clearly define it.

The Basic Steps Of The Process

1. Identify the Need: Recognize the specific scenarios in your optical design process where a custom feature could enhance efficiency or address limitations. 2. Form a concept of how to implement: Can a feature be created with simple script or do you need a more powerful DLL-based object.

2. Design and Implement: Plan and design your custom feature, keeping your project’s requirements in mind. Implement it within Zemax, ensuring that it integrates seamlessly into your workflow.

3. Testing and Validation: Thoroughly test your custom feature to ensure it behaves as intended and provides the expected results. Validate it against your design requirements.

4. Documentation: Document your custom feature, including usage instructions and any unique considerations for future reference.

5. Share Knowledge: Consider sharing your custom features within the Zemax community if they have broad relevance. Collaborative innovation benefits everyone in the optics field!

Example – Automatically collimating shape

In optics it is quite common to use collimating shapes. This can be either one component within an optical system that sets the focus to infinity or just a simple lens producing a narrow beam from an LED light source. Collimating shapes are integral in maintaining the precision, accuracy, and efficiency in Optics, Sensors and Detectors, Laser Technology, Medical Imaging. As an example, let us consider an entrance surface that requires to have a collimating shape.

In sequential (SC) mode of Zemax such surface is easy to define and constrain within the merit function. However, in non-sequential (NSC) mode, adding such constrain to one surface within a merit function can be quite time-consuming in an optimization. If you  know that a certain part of your design must always have theoretical collimating shape, it would be best to define it as constantly collimating in relation focal distance and index of refraction, while maintaining flexibility to positional changes. This way, you would not need Zemax to consider this in optimization, freeing up valuable calculation time, especially in NSC. Such a feature could be defined within Zemax Programming Language (ZPL) script or be embedded into a User-Defined Object (UDO). If you want to know more about UDO, please see next chapter “For Programming Enthusiasts” for details.

Conclusion

In conclusion, user-defined custom features in Zemax are powerful tools that empower optical designers and engineers to overcome challenges, improve efficiency, and maintain precision in their work. Whether you’re dealing with non-standard components, repetitive calculations, or persistent design workarounds, harnessing the potential of customization within Ansys Zemax can elevate your optical design projects to new heights of efficiency and innovation.

For Programming Enthusiasts

The easiest way to tackle the example described in previous chapter would be to write a simple Zemax Programming Language (ZPL) script with the Zemax macro language. As there is less information about User-Defined Surfaces (UDS) and User Defined Objects (UDOs), let us approach this by using VB.net programming. General information about UDOs is covered in Zemax Knowledge-Base article KA-01846, which I recommend going through before reading this.

The anatomy of UDOs is specific. Zemax expects an entry-point to a DLL function with a specific name, carrying pointers to two objects with specific structures called UD and FD (User Data and Fixed Data). Some more experienced programmers might realize at this point, that DLL export functionality is only provided in native C and C++ language. However, I have good news for those who prefer VB.NET and C#: There is a way around this, but it will require a little bit of compiler configuration and marshalling, which I am looking forward to cover in detail in a PDSVISION Conference talk.

Below example (Snippet 1) shows, how the called function is defined using version 3 of UDS surfaces. Version histories are better discussed in the above mentioned Knowledge Base article, but the key is, that the expected entry point has to be named as “UserDefinedSurface3”, while also having corresponding “FIXED_DATA3” structure (Snippet 2) for the FD object.

A User Data object UD (Snippet 3) has only one structure. As Zemax is written in C and this example is provided in VB.NET, some Marshalling will be required for the interpretation. Also, please bear in mind that the name of called function should remain unchanged after the compilation, which might not always be the case. Inside the called function we will have the communication routine for data exchange, which will provide Zemax the object parameters, parameter names, object behaviour, and more, for which there are plenty of examples available in the “..User\Documents\Zemax\DLL” -folder.

In our case example, we would only adjust the conic value according to index of refraction reported by Zemax. Index of refraction is included in FIXED_DATA3 n1 and n2 pointers, and the values will change whenever the material will be changed in the Lens Data Editor (LDE). We can simply read the index values, apply them to the equation, and set the conic value accordingly. The other part of equation states, that radius should be half of the distance from focal point. For the sake of simplicity, this can be defined as pick-up value in LDE, however it is also possible to import it straight to DLL object to make it fully independent.

 

Snippet 1. Definition of the DLL function.

Snippet 2. Structure of the fixed data object.

Snippet 3. Structure of user data object.

 

Did this spark any interest? Contact us HERE! 

 

Olli Hakala, Senior Optical Engineer

Social media

Follow us on our social media platforms


RELATED BLOG POSTS

Time to migrate from Mathcad 15 to Mathcad Prime 9 – Tips & Tricks

Time to migrate your Mathcad 15 worksheets to Mathcad Prime 9! It is time to migrate your Mathcad 15......
Read more

PDSVISION and CrossControl Partner for a Digital Transformation Journey.

 PDSVISION and CrossControl Partner for a Digital Transformation Journey Stockholm, Sweden - November 27,......
Read more

6 ways myPDS Search can help your R&D

6 ways myPDS Search can help your R&D I understand the frustration of R&D- and construction......
Read more

Making Engineering Calculations Easy

Making Engineering Calculations Easy Mathcad Prime is all about making engineering calculations easy.......
Read more

Unleashing Your Inner Nature Lover: Volunteering With Our National Forests – Part 2

This is the second update from PDSVISION’s Matt Sweitzer. Matt spent the summer working as a steward of the......
Read more

Change Management Streamlined

The world has seen a whirlwind of transformations, yet the essence of change management remains as crucial as......
Read more

KeyShot 2023: The latest enhancements

With the new version 2023, the KeyShot team has made a number of enhancements to help you work faster and......
Read more

Modeling a robotic Lego arm – Summer Internship 2023

Modeling a robotic Lego arm – Summer Internship 2023 PDSVISION offers a summer internship program to......
Read more

Ansys 2023 R2: Highlights, Synergies and Interoperability with PTC and Altium

Ansys 2023 R2: Highlights, Synergies and Interoperability with PTC and Altium This blog will explore some......
Read more

PDSVISION Empowers Digital Transformation with Codebeamer 2.0: Unleashing Productivity and Control

Codebeamer 2.0 brings significant performance improvements....
Read more

The Flash LIDAR and Its Effect on Consumer Electronics

The Flash LIDAR and Its Effect on Consumer Electronics  Let's take a look at flash LIDAR, a subset of......
Read more

Dynamic positioning with Options and Variants in Windchill.

Dynamic positioning with Options and Variants in Windchill Dynamic positioning is a topic related to......
Read more

ECAD-Simulation collaboration for PCB design process

ECAD-Simulation collaboration for PCB design process; an example with Altium and Ansys SIwave Using......
Read more

Ansys Mechanical 2023R1 – the Top 5 features

Ansys Mechanical 2023R1 – the Top 5 features Every year, Ansys Mechanical releases new features that push......
Read more

Unleashing Your Inner Nature Lover: Volunteering With Our National Forests

Matt Sweitzer joined PDSVISION US in 2023 as a part of our merger with Boston Engineering. When he is not......
Read more

I want to move PTC Windchill to the Cloud – What are my options?

Want to move PTC Windchill to the Cloud? myPDS Cloud removes the burden from your IT team, with all the......
Read more

Optimize your Ansys licensing with Ansys Elastic Currency

Top tips to optimize your Ansys Licensing! Are you new to Ansys simulation and not sure which license model......
Read more

PTC Creo 10 is here

Creo 10 is here with a wide variety of improvements to help make every day more productiveThese include......
Read more

Connected products extend the digital thread

Digital Thread PDSVISION supports manufacturing companies in their digital transformation by enabling the......
Read more

Leaving Information Island

Democratizing information is a cornerstone for a successful Digital TransformationIn projects that aim to......
Read more

Mathcad Prime 9

Solve your most complex problems with the new and improved Mathcad Prime 9 Mathcad Prime 9 has finally......
Read more

The undoubted benefits of implementing a PDM system

For any product development company, the PDM System (Product Data Management) is an essential component as it......
Read more

PDSFORUM – An event that inspires digital transformation

An event that inspires digital transformation Every step in the value chain — from product engineering to......
Read more

Creo combined with Ansys Mechanical – Your Competitive Advantage In Product Design

The challenge of designing winning products is getting more difficult by the day. The choices made in the......
Read more

KeyShot 11.3 for Apple Silicon – Speed Gains and Improved Performance

Keyshot 11.3 is the latest version of Luxion's powerful 3D rendering and animation software designed for......
Read more

Materials make the world go round

The meaning of the word “material” conjures up different ideas for different people. For some, the look......
Read more

Contextual Data for IoT

Meaning of data from IoT sources If you have ever read Hitchhiker’s Guide to the Galaxy, you would know......
Read more

Using Functional Safety and Reliability for a competitive advantage

Functional Safety and Reliability is a hot topic that stimulates many discussions, depending on the......
Read more

PDSVISION and Renholmen extend their collaboration

Thoroughness drives innovation, and no detail is insignificant. Work hard to make the customers satisfied and......
Read more

Getting Started with IoT for Manufacturing

“In the beginning … the earth was formless and empty.”  – Genesis Where to begin? That is a good......
Read more

What’s new in Luxion’s Keyshot 11.2?

Keyshot 11.2! This version offers a range of powerful new features that allow users to create stunning......
Read more

PDSVISION and PTC have together helped further Electrolux Professional’s digital transformation

As a highly profitable, customer-centric business trusted by over half of Europe’s Michelin-star......
Read more

PTC Creo 9 is here – Available via PDSVISION

Creo 9  has landed with a range of updates, new features, and options designed to significantly accelerate......
Read more

PTC Creo 9 – What’s New?

There has been an addition to the PTC family of Design Solutions; PTC Creo 9 has arrived! PTC Creo 9.0 is......
Read more

Compliance within MedTech and the medical device industry

Today's product development faces several challenges, and one of the biggest challenges is regulatory......
Read more

Accelerate digitization with myPDS applications

PDSVISION launches 9 powerful applications to accelerate digitization in the manufacturing......
Read more

Short facts about KeyShot version 11.1

This version includes several new features and improvements that will make creating amazing visuals faster......
Read more

Getting Vuforia Engine setup in Unity in 2022

Vuforia Engine is a software development kit (SDK) for creating Augmented Reality apps. Developers can......
Read more

Integrate ECAD with PLM to achieve full product definition

As PLM Business Director, I meet with companies from different industries daily. It is apparent that all......
Read more

KeyShot 11 – Now Available!

The world of visualization infinitely expanded with KeyShot 11 – now available via PDSVISION KeyShot 11 is......
Read more

Enterprise Visualization in the Product and Service Lifecycle Business – one unified automated publication pipeline

As part of digital transformation roadmaps, industrial companies explore enterprise visualization to enhance......
Read more

10 useful Creo Parametric features you should be using in 2022

One of the reasons why Creo Parametric has grown in popularity among engineers is due to the software’s......
Read more

Professional Windchill Training: What can you expect?

Enhance your skills in PTC Windchill PTC Windchill training is the most effective way to build your......
Read more

Professional Mathcad Training: What can you expect?

Engineering calculations for everyone - in PTC Mathcad One of the main advantages of Mathcad over its......
Read more

Professional Creo Training: What can you expect?

Accelerate your skills in PTC Creo This blog post briefly explains what you should expect when coming on a......
Read more

Professional KeyShot Training: What can you expect?

KeyShot training to accelerate creation of amazing photo-renderings and animations KeyShot training is......
Read more

Who needs Creo? – A look into the capabilities and benefits of Creo

Three great news in Creo 8.0 Anyone interested in 3D CAD and specifically product design should look no......
Read more

Factors to consider when choosing a CAD system

Choosing a CAD system is an important and potentially daunting business decision. In this article I will go......
Read more

Creo for entrepreneurs and Start-Ups

The optimal way to jumpstart your business Starting a new business is an exciting and challenging time –......
Read more

BOM Management: Defining your digital products

Why is BoM Management important? Accurately managing the holistic bill of materials (BoM) across fragmented......
Read more

Industry 4.0: Transforming Manufacturing In The UK 2021

What is Industry 4.0? Allowing your business to transform its manufacturing means that that you're allowing......
Read more

Reduce CO2 emissions/environmental footprint with Augmented Reality/Vuforia

Reducing our environmental footprint with Augmented Reality and Vuforia A hot topic for many businesses are......
Read more

The Best Industrial Augmented Reality Platform

What is Vuforia? Vuforia is PTC's enterprise-level Augmented Reality (AR) product suite and one of the best......
Read more

Importance of a Digital Transformation strategy

Research from IDC states that ‘‘The demand for Digital Transformation is coming from customers and......
Read more

Experts in product and packaging design company Noun chooses KeyShot and PDSVISION

Noun is a design studio based in Stockholm, Sweden, that specializes in product and packaging design. Noun......
Read more

ANSYS Discovery – Introduction

After long and sunny summer, the fall starts to kick in. Now is the time to get geared up for the winter’s......
Read more

How is Augmented Reality Changing Engineering?

Augmented Reality In Engineering Everything we do in engineering - before we actually make anything - tends......
Read more

Vuforia Instruct – Complementing PTC’s Industrial AR solutions suite!

  Vuforia, the award-winning and leading Augmented Reality reality solution-centric......
Read more

The Handyman and The Gentleman – AR #7 – Vuforia Work Instructions

To continue discussing how relevant Augmented Reality (AR) is for the industrial enterprise, in this blog, I......
Read more

What is the ‘’Internet of Things (IoT)’’, and why is it important?

Connect products, facilities and people with IoT The phrase internet of things or IoT is thrown around a......
Read more

Digital Transformation is happening – Don’t get left behind

Digital transformation is here, and it will affect everything we do. Digital transformation is happening –......
Read more

Working on our ways of working – to support our customer projects in a better way

At PDSVISION we strive to be the best at what we do, and we have always been proud of our deliveries and our......
Read more

PTC Creo 8 – What’s New?

There has been an addition to the PTC family of Design Solutions, PTC Creo 8 has arrived! When an update to......
Read more

The Handyman and The Gentleman – AR #6 – Capture, Edit & Author

In my previous blogs, I have shown and discussed how the PTC Vuforia family of solutions is becoming the......
Read more

OnDosis chooses PDSVISION on their journey into improving healthcare

OnDosis develops products used for flexible and individualized dosing of oral medicines for diseases with a......
Read more

Mathcad Prime 7.0 is here!

PTC have released the seventh version of the Mathcad Prime calculation software which includes a range of......
Read more

The Handyman and The Gentleman – AR #5 – Vuforia Expert Capture – Simple, Secure and Smart

In this blog, the fifth in my series based around my Augmented Reality video series "The Handyman and The......
Read more

The Handyman and The Gentleman – AR #4 – Vuforia Expert Capture

I’ve spoken recently in blogs on how AR applications (Augmented Reality) such as PTC Vuforia Chalk can......
Read more

Creo Parametric Behavioral Modeling Extension

Design automation for various design goals with PTC Creo Parametric Behavioral Modeling Extension......
Read more

PTC’s Vuforia – Top 5 use cases

Our top 5 Vuforia use cases from our experts In this post our very own Vuforia Experts here at PDSVISION......
Read more

The Handyman and The Gentleman – AR #3 – Working Hands Free

In my previous blog I explored with you how such a simple task as an onsite customer maintenance task or......
Read more

The Handyman and the Christmas StARs

"How can Augmented Reality come to my aid as I face my biggest challenge since joining PDSVISION?Making......
Read more

The Handyman and The Gentleman – AR #2 Problem Resolution

All business’ understand the importance of getting the work done correctly and to standard the first time.......
Read more

Keyshot 10 – Now Available

KeyShot 10 brings unbound creative capability to help realize your ideas faster. It is built as the hub for......
Read more

Trimble AB Invest In Luxion Keyshot

[caption id="attachment_10854" align="alignleft" width="300"] Image: Trimble[/caption] Luxion KeyShot is the......
Read more

The Handyman and The Gentleman – AR #1 – Getting Work Done

Imagine you’re a Field Technician, sent out to a customer to perform scheduled customer maintenance.......
Read more

Ambulansproduktion and PDSVISION continue their joint journey!

Ambulansproduktion develops the markets most innovative and robust ambulances. These ambulances create safety......
Read more

Energy Machines and PDSVISION initiate collaboration!

Energy Machines and PDSVISION started collaboration around both CAD and PLM components, last week. This with......
Read more

Before you can really consider AR and VR, you need to get the conversation going!

Before you can really consider if AR and VR will have a beneficial impact on your business, you need to get......
Read more

PTC Creo Parametric ( Pro/ENGINEER) vs. Solidworks – The Second Coming

Hello, do not worry, I am not intending to discuss with you W. B. Yeat's famous poem from 1919 today! No, I......
Read more

How do I create a single part in the context of the assembly in PTC Creo Parametric?

For historical reasons, PDSVISION Germany has many customers who use Creo Elements / Direct Modelling.......
Read more

AR – Meeting the Industrial Enterprise needs in manufacturing

My clients ask, "How can AR make our production staff and manufacturing process more efficient?" Is there a......
Read more

The Need of Digital Twins to Support Circular Economy

PDSVISION has recently participated in the EU Commission funded Horizon 2020 project studying circular......
Read more

Whats new in PTC Creo 7.0?

Here in Finland, Spring returns and brings new sprouts from the ground, leaves to trees and endless sunshine......
Read more

PTC Creo vs SOLIDWORKS

Rivalry between Creo vs SolidWorks. As a senior consultant for PDSVISION I spend a lot of time with......
Read more

Getting things done remotely, in a world that almost changed overnight

Vuforia Chalk - The solution to the collaboration challenges we face within 3d design With people’s......
Read more

Ansys – More Than Just Simulation

We at PDSVISION have supplied solutions around Ansys portfolio of products for some years, especially Ansys......
Read more

5 Reasons to invest in KeyShot

Create 3D renderings, animations and interactive visuals. KeyShot is Luxions globally known stand-alone......
Read more

PDSFORUM – time well invested

PDSFORUM – time well invested"4.5 out of 5 in the score for our workshops" Participant survey"The most......
Read more

Delivering value with Augmented Reality

A conference room filled to the breaking point was the scenario when we hosted a breakfast seminar together......
Read more

Getting started with PTC Creo Simulation Live now easier than ever!

PTC Creo Simulation Live is one of the first results to come form the partnership between PTC and Ansys. It......
Read more

BoM Transformation – Product Lifecycle Data is Created in Engineering

[caption id="attachment_7471" align="alignright" width="300"] BoM Management in PTC......
Read more

Change Management – A Cornerstone

"….most design is a variation from or modification to, an already existing product or machine".(Cross,......
Read more

PTC Creo – The best CAD software on the market today

Religion, politics, what football team you cheer for, some topics can generate emotions instantly when......
Read more

Creating Inheritance Models for Manufacturing with Creo Parametric (Formerly Pro/ENGINEER)

In design, the question often arises as to how you can design so that you do not have any problems later on,......
Read more

The benefits of using myPDS Configurator

I find PTC Creo Parametric as an excellent 3D CAD solution for large, configurable assemblies. Creo......
Read more

Different Product Configuration Approaches

Product Configurators gives companies a possibility to manage product variants in an efficient way, for PTC......
Read more

Windchill 11.1 – PLM in the modern web

Windchill 11.0 has been around for the last two years. With its release PTC started a journey to renew the......
Read more

Creo 5.0 Update

The PTC Creo 5.0 release is jam packed with new features, Topology optimization studies, built in flow......
Read more

Saving Heat Treatment Steps Means Saving Costs

Cut manufacturing costs with MAGMASoft Many of our customers ask me if we can help them to cut manufacturing......
Read more

3D printing with Creo Parametric

3D printing or, a bit more technically phrased, Additive Manufacturing, may be on everyone’s lips and......
Read more

myPDS Apps – What problem do they solve?

PDSVISION has been developing for years add-on solutions for PTC software users. I am regularly asked why are......
Read more

Security in PTC Windchill – Part 2 of 2

In my last post on the theme security in Windchill I provided some general tips for creating a safer server......
Read more

Great features in Creo Simulate

Some hints on existing functionality that one might not be so familiar with and some features from Creo......
Read more

XML – DITA, DocBook, S1000D or Shipdex – Are you confused?

More and more, technical writers are realizing the value of XML as a format to use for their document......
Read more

Security in PLM System Windchill – Part 1 of 2

Security is something we often seem to take for granted. The problem with this is when something goes wrong,......
Read more

Take Control of your Creo Parametric modeling

Many companies are continuously expanding their utilization of 3D CAD. Both for manufacturing material but......
Read more

Five tips from our Support

Our Support team helps our customers worldwide with our solutions, Creo (3D CAD), Windchill (PLM), Simulation......
Read more

Life as a Support Engineer at PDSVISION Support

Working as a support engineer at PDSVISION Support is a varied job and no day is like the other as you get to......
Read more

11 great improvements in Windchill 11 – Part 2 of 2

PTC Windchill 11 was launched 15th of November, the top highlights - Top down support of Find Numbers......
Read more

What is your IoT strategy?

Business leaders are today aware of the potential of the Internet of Things (IoT) to fundamentally change......
Read more

11 great improvements in Windchill 11 – Part 1 of 2

This is part 1 of my Windchill blog review of the improvements in PTC Windchill 11.0 (PTC Windchill PDMLink),......
Read more