How To Ask A Good Programming Question

Blog 3.1.2019 No Comments

In a hurry? Skip right to the section called Guidelines for the meat of this article.


Over one year ago we introduced tech support through Slack, where you can ask your SOLIDWORKS API and PDM API questions to our team and get high-quality answers within hours or even minutes. Our members have absolutely loved it for its speed and simplicity. But whether you’re posting in our Slack, the SOLIDWORKS API forum, or StackOverflow for a general programming question, these four little words carry so much truth:

“Help us help you.”

Indeed, one of the most frustrating parts of using any technical support resource, whether you’re helping others or simply doing research, is wading through a long thread in which the experts are trying to extract all of the necessary information from the asker so they can actually offer help. Technical help sites like StackOverflow deal with this problem by using a Q&A format instead of a forum / thread format, but they still constantly delete low-quality questions in which the asker didn’t “help us help you”.

All of this to say: asking a well-written programming-related question takes a lot of effort and is not intuitive to many askers. In this post I hope I can give you some clear-cut rules for guaranteeing that your question conveys all of the information necessary for an expert to help you get the answer you need as quickly as possible. By doing so you will protect your time and theirs.


1. Keep it short, simple, and to the point

a. Your first sentence should state your question or summarize your problem.
b. Questions with unnecessary details and background explanations are harder to answer.
c. Use a bullet or number list to convey details. They’re easier to read than paragraphs.
d. Break complicated problems down into smaller problems and post about each problem separately.

2. Share the minimum amount of info necessary to completely convey the problem

a. Please post any relevant code. If you do post code:
    i. Only include code that is necessary to repeat the problem.
    ii. Your code should compile. Do not post a code snippet that others are forced to complete in order to test.
b. If you’re getting an error message, share that error message and what line it occurs on.
c. If your problem occurs only under a certain situation in SolidWorks (e.g., when a certain model is oepn):
    i. State specifically what that situation is.
    ii. Include the simplest possible model that includes that situation, if necessary.

3. Proofread your question

a. At CADSharp, we speak over fifteen languages between all of our technical support representatives. If you would prefer to receive help in another language, just ask. But no matter what language you use, be sure to proofread your question so its as clear as possible.


Let me share an example of poor a question / request:


My boss has asked me to write some macros that prepare our models for-check in. The macro needs to check each part and add a Material property if it doesn’t exist. Should also put the Description property in each configuration and the delete the Author property. Works on my test models but stopped working on my production models. Here is the code:

swModel.DeleteCustomInfo2("Default", "test")


Unfortunately, this help request is so lacking that I would be wasting my time even trying to help this person. The main reason is that I would be guessing as to what their problem is and might potentially solve a problem they don’t have. Specifically, this is how this question should be improved:

1. Clarify whether the macro is run in a part, assembly, or both.
2. Clarify whether custom properties are supposed to be added to assembly components or only part components.
3. Clarify whether the Description property is supposed to be moved or copied.
4. Clarify whether the Author property is deleted from the document-level custom properties, the configuration-level custom properties, or both.
5. Use bullet or number lists to differentiate the different problems.
6. Give an explanation of what “stopped working” means. Does it mean the macro runs successfully but produces incorrect results or does it mean that an error occurs (and what is the error message)? Does it refer to some or all of the tasks?
7. Include the full source code.
8. Include a sample model.

Obviously this is an exaggerated example, but I have read some help requests before like this. Keep in mind: technical support cannot read your mind. Instead of assuming they are familiar with your workflow (simply because it makes so much sense to you!), put yourself in their shoes and ask, “What would they need need to know to solve my issue?”

The XY Problem

The above guidelines assume that the asker knows what their problem is. Sometimes, this isn’t the case, and it can waste a lot of time for both the asker and the support technician. The situation I’m speaking of is known as the XY Problem. It occurs when someone asks for help with their attempted solution rather than their actual problem. A good example in the SOLIDWORKS API world would be someone asking for help on getting a point on a face so they can select it with IModelDocExtenion.SelectByID2, when in reality they should have simply asked for help on how the best way to select a particular face, because the aforementioned API call is not appropriate for selecting faces.

Basically, the XY Problem is a technical term to describe askers who are ignorantly pursuing the wrong solution. While its great to encourage people to step back and think, “What problem am I actually trying to solve?”, the XY problem itself is problematic for two reasons:

1. Sometimes its just as much a waste of time to wade through lots of background information on the problem only to discover that the user was pursuing the correct solution.
2. The simple fact is that much of the time the asker will not know enough about the subject at hand to know whether they are asking the wrong the question. In that case, it is the support technician’s responsibility to ask the questions necessary to uncover the actual problem.

I get the impression that this term was coined by support technicians or forum participants who easily get annoyed helping askers — which is frequently the case on sites like StackOverflow, some of whose users are known for their alarming rudeness and presumptuousness.

When you use CADSharp’s technical support, you can be assured that even if you’re asking the wrong question, you will always be treated with kindness and patience, because its our pleasure to help you reach your SOLIDWORKS API and PDM API automation goals.

Helping you help us help you,

Want to keep up with future content and training events? Sign up for our newsletter.

Leave Comment

CADSharpTools: .NET Developer Toolkit

Blog 8.13.2018 No Comments

CADSharp is pleased to announce that our industry-leading SOLIDWORKS API and SOLIDWORKS PDM API libraries are now available to Power User members. This is the ultimate toolkit for those who want to speed up their .NET addin and stand-alone development by utilizing our hand-made library of commonly used functions and classes. Best of all, it’s regularly updated by CADSharp team members with great new functionality.


Possibly the best way to demonstrate the power of this toolset is to compare two addins, one that uses CADSharpTools and one that does not. These addins both accomplish the same thing: creating dropdown menus in SolidWorks that appear in particular document types and display message boxes when clicked.

You will notice that the example using CADSharpTools requires fewer imports, fewer classes, fewer lines of code (about a third less), and is much more readable. More importantly, you can imagine how much faster developing an addin is using CADSharpTools. You can set up your own template with CADSharpTools already utilized or quickly update old addins. You might even discover a better way to accomplish certain tasks using our toolset.


Note: While this is complete list of classes, the descriptions do not state all functionality in each class.


Contains classes that let you easily create drop-down menus and CommandManager tabs (saving you possibly hundreds of lines of code), register and unregister your addin with SolidWorks, and perform “cleanup” when unloading the addin.


Contains functions that let you rename components, get a component’s instance, get a component’s name without the instance number, and create an array of unique components in the assembly.


Contains dozens of useful file extension and file filter constants.


Lets you input your Document Manager license key via the constructor and then easily work with a document’s custom properties, get a document’s configuration names, and more.


Provides flexible options for searching for and updating notes, getting a note’s position relative to the sheet margin, and locating views.


Lets you store a spreadsheet’s contents in a .NET DataTable, get worksheet and workbook pointers, create Excel visibly or invisibly, quit Excel, and determine if any Excel processes are active.


Lets you safely create, copy, delete, and rename files and folders in Windows. You can also determine if a file is read-only, verify its extension, verify whether a file name is legal, and read text files.


Lets you sort ListView controls in ascending or descending order, as well as create file and folder browsers that add the browsed location to a text box.


Lets you easily handle various aspects of logging, namely creating the log entries and accessing the log folder in the user’s AppData folder.


Performs various tasks related to two or more SolidWorks model types, including toggling graphics updating, creating named views, working with display states, creating a pack and go, and saving the model (Save or Save As) in any format.


Performs tasks related to parts, including getting IBody2 pointer given a body name, getting a body’s folder feature, and getting a body’s cut list feature.


Lets you create an instance of a SolidWorks (for use with a stand-alone) with the ability to specify the desired year if multiple installations are present, exit SolidWorks (for use with a stand-alone), determine if any SolidWorks processes are active, open a SolidWorks model, get a model’s document type from its file path, and get a list of all SolidWorks models of a particular type in a folder.


Lets you search geometry and topology, such as getting the length of an edge and getting the largest planar face in a body.


Lets you easily get the data from a project’s Assembly Information, display a message with the product name as the title, save out an embedded icon to the local disk and get its file path, convert an enumerator to string, and compare two values given a tolerance.


Lets you read read a specific XML node, update a specific XML node, and get a list of all material names in a SolidWorks material database.

How Can I Use It?

If you are a Power User member and wish to use CADSharpTools then you may visit our this page to learn how to obtain it. You can either download the DLL and add it as a reference to your project or you can copy and paste individual portions of the source code into your code. The documentation is available in the repository. You can also submit bug reports and enhancement requests using the repository’s built-in issue tracker. If you’re new to online repositories and have any questions, let us know.

Think of it as similar to our Macro Library, except 1) the entire codebase can be downloaded and referenced in a project, 2) the codebase is in .NET. As long as you kindly do not share the DLL or the code outside of your organization with individuals who aren’t CADSharp, the sky is the limit. (Note: it is fine to use the code in a project that you will sell to a customer. Please the entire Usage Agreement here.)

Want to keep up with future content and training events? Sign up for our newsletter.

Leave Comment

Fix These 4 Common PDM Vault Addin Errors

Blog 8.1.2018 No Comments

Have you ever attempted to develop a SOLIDWORKS PDM addin and run into errors when adding it to the vault? This short posts discusses four different types of errors one might actually see when adding a new PDM addin to a vault.

1. The DLL is not com module 

This error simply means that your DLL is com-compliant. Your types were not registered for com interops and probably are not com-visible. You can fix this by:

  • Decorating the class with the ComVisible(“true”) attribute and guid:

  • Going to Project > Build (Compile for VB.NET) and then checking register for com interop.

2. Please Select at least one DLL implementing the IEdmAddIn5 Interface


Your add-in class must  implement the IEDMAddIn5 interface.  To implement this interface, you must reference a dll that contains this interface.

  • Add a reference to <SOLIDWORKS PDM INSTALLATION FOLDER>/EPDM.interop.epdm.dll. This assumes you are writing a add-in for CLR4 (SOLIDWORKS 2013 and newer). Here’s a table that summarises the different versions of the PDM interops:
     PDM Professional versions… Support .NET Framework…
    2013 and later 4.0 and later
    2009 – 2012 3.5, 3.0, and 2.0
    2008 and earlier 2.0

    To target earlier version of the CLR, follow this link for instructions.

  • Implement the interface like follow:

    Normally, after writing MyPDMAddInClass : IEdmAddIn5, Visual Studio will show a squiggly line under IEdmAddIn5, press Ctrl + ; and then implement explicity:

3. The add-in ‘<Path>’ cannot be installed since it returned an invalid required version SOLIDWORKS PDM version from its GetAddInInfo Method

This is because of an incomplete implementation of the GetAddInInfo method. A sample implementation of the GetAddInInfo would look like this:

4. The archive server could not open  the Windows registry

This error is because of windows permissions. If you are running Windows 7/10, make sure the run the administration tool with administrator privileges.
If you have downloaded the add-in dll, make sure it’s not blocked by windows. To unblock, simply right on it and go to properties:

Questions or comments? Please share in the comments below!

Amen Jlili

Want to keep up with future content and training events? Join our newsletter!

Leave Comment