What’s New In The SolidWorks 2017 API

Blog 10.1.2016 No Comments

It’s that time of year again, folks. Let’s look over some of the most notable enhancements to the SolidWorks API, as well as some tips for using the API Help most effectively.

  • Create and access selection sets. (ISelectionSet)
  • Traverse the Manager Pane and activate the FeatureManager design tree, PropertyManager, ConfigurationManager, DimXpertManager, DisplayManager, or custom tab. (IModelViewManager::ActiveFeatureManagerTabIndex)
  • Fire a pre-notification and notification when activating a tab in the Manager Pane. (See swPartCommandManagerTabActivatedPreNotify and swPartActiveDisplayStateChangePostNotify in swPartNotify_e, swAssemblyNotify_e, swwDrawingNotify_e)
  • Get whether an axis is a temporary axis and get its reference face. (IRefAxis::IsTempAxis, IRefAxis::GetTempAxisReferenceFace)
  • Get or set the state of a check box on a PropertyManager page. (IPropertyManagerPageCheckBox::State)
  • Offset selected edges to create a 3D sketch on a face or surface. (IModelDocExtension::SketchOffsetOnSurface)
  • Make a selected component independent. (IAssemblyDoc::MakeIndependent)
  • Control the isolation state of components. (IAssemblyDoc::Isolate, ExitIsolate, SetIsolateVisibility, SaveIsolate)
  • Get the names of the exploded views for a specific configuration, get the number of exploded views in a specific configuration, and get the name of the configuration for a specific exploded view in an assembly.
  • Get the name of the exploded view in a specified configuration. (IAssemblyDoc::GetExplodedViewNames2)
  • Get the name of the configuration for the specified exploded view. (IAssemblyDoc::GetExplodedViewConfigurationName)
  • Get the collapsed or exploded transform of a component when the assembly is exploded. (IComponent2::GetSpecificTransform)
  • Delete either the selected components of a subassembly or the subassembly of the selected component. (IAssemblyDoc::DeleteSelections)
  • Get or set whether to disable an equation and get the number of disabled equations in a model. (IEquationMgr::Disabled, GetDisabledEquationCount)
  • Specify a sketch plane, surface/face/plane, vertex, or offset as a start condition when creating an extruded surface. (IFeatureManager::FeatureExtruRefSurface3)
  • Specify multiple drawing sheets whose setups to modify. (IDrawingDoc::SetSheetsSelected)
  • Create SpeedPak configurations for subassemblies in an assembly. (IAssemblyDoc::SetSpeedPakConfigurations)
  • Rebuild all features or rebuild only those features that need to be rebuilt in all configurations without activating each configuration in a model. (IModelDocExtension::ForceRebuildAll)

You can see all new API calls and interfaces in the Release Notes article in the API Help. You can find it in the local API Help by searching for “Release Notes” in the category tab. Note that the local API Help Release Notes will only be as up-to-date as the service pack you have downloaded.

Tips and tricks for using the SolidWorks API most effectively:

  • Use the local SolidWorks API Help. Besides being easier to navigate than the online help and not requiring SolidWorks to be open, it is also updated each service pack, whereas the online help is only updated for SP0, SP1, and SP5.
  • If you reference the local SolidWorks API Help as often as I do, it’s more convenient to create a start menu, task bar, or desktop shortcut directly to the latest SolidWorks API Help rather than accessing it only through the SolidWorks Help menu. What I do, therefore, is create a shortcut for <SolidWorks installation folder>\api\apihelp.chm and drag this shortcut onto my start menu icon, task bar, or desktop. I’d recommend that you rename the shortcut something like “SolidWorks 2017 API Help” so you know what version it refers to.
  • If you discover an area where the API is lacking, don’t be afraid to submit it to the SolidWorks API support team. On every local API help page is a “Send comments” link at the top and on every online API help page is a “Feedback on this topic” link.

Keith

Keep up with future CADSharp.com content, training events, and special offers via our newsletter:


Leave Comment

What’s New In The SolidWorks 2016 API

Blog 11.1.2015 2 Comments

SolidWorks 2016

Another year, another round of SolidWorks API enhancements. Let’s run through the most notable:

  • Get corresponding sketch contours, sketch segments, and annotations for a specific instance of a component in the context of an assembly.
  • Get or set the properties of paragraphs in note annotations.
  • Get or set cross break feature data in sheet metal parts.
  • Get or set indent feature data.
  • Get or set boundary feature data.
  • Get or set chain pattern feature data.
  • Insert a structural weldment feature using a configuration in a custom weldment profile.
  • Get or set the name of the configuration in a custom weldment profile for a structural member.
  • Get or set hole callout variables.
  • Get or set gaps between center marks and extension lines, add center marks to a center mark set, get whether center marks are detached, get whether entities have detached center marks in a center mark set, reattach center marks to a center mark set, and get the coordinates of center marks.
  • Get or set options for ray-trace rendering engines, including the option to include annotations and dimensions visible in the model in the final render.
  • Make the child components of a component virtual when the component is made virtual.
  • Get the name of the drawing zone for the specified x and y coordinates on the drawing sheet.
  • Reload the sheet format from the original sheet format template.
  • Support for these leader styles: Attach Leader Bottom, Attach Leader Center,
  • Attach Leader Nearest, and Attach Leader Top.
  • Set geometric tolerance values and datum references in gtol symbol frames.
  • Get or set whether to display hole sizes in hole tables using ANSI inch letters and drill numbers.
  • Get or set the message to display in the What’s Wrong dialog box when a non-embedded macro feature fails to rebuild due to missing files.
  • Get the actual mass properties of selected components in a model.
  • Get or set the “Same as sheet specified in Document Properties” check box in the Sheet Properties dialog box.
  • Specify whether to convert the inner loops of the selected faces to sketch entities on a sketch plane.
  • Get the name of a sketch segment.
  • Get or set curvature continuous for a variable radius fillet feature.
  • Fire an event when an assembly component is about to be renamed.
  • For SolidWorks MBD: 1) Publish to 3D PDF, 2) Create a general table annotation for 3D PDF, 3) Support for exporting decals and textures to 3D PDF. (New in SolidWorks 2015, SolidWorks MDB (Model Based Definition) is an integrated drawingless manufacturing solution for SolidWorks.)

Want to see the API interfaces and calls related to each of these topics? Check out the Release Notes article in the local or online API Help. You can find it in the local API Help by searching for “Release Notes” in the category tab. Note that the local API Help Release Notes will only be as up-to-date as the service pack you have downloaded. Also note that the online API Help is only updated for SP0, SP1, and SP5.

As always, if you discover an area where the API is lacking, don’t be afraid to submit it to the SolidWorks API support team.

Keith

Want to keep up with future CADSharp.com content, training events, and special offers? Sign up for our newsletter.


Leave Comment

API Programming Contest #2 Winners!

Blog 7.6.2015 No Comments

This year’s SolidWorks API programming contest, sponsored by CADSharp, brought in five fascinating submissions. This may seem like a low number, but I quite pleased considering the complexity of the contest. If you aren’t familiar with the contest rules, visit here.

My intention with the contest is that entrants would use geometry/topology traversal techniques to find the appropriate entities for mating. I did not, however, specify sufficient contest parameters to ensure this outcome, as I quickly discovered. Rather than penalizing the individuals who used alternative approaches that technically were within the boundaries of the contest, I have decided to awards prizes to all entrants.

Download submissions (.swp files)

Each .swp is named after the initials of the entrant. Let’s discuss each one, from shortest to longest:

1. rj.swp A very clever solution that utilizes the ability to put multiple statements on the same line as long as each statement can return a value. Even if you split up the conditional statements onto different lines, this macro still comes out to less than 30 lines. Rajat obtained the mating entities by hard-coding the feature names and considering the face order in the array returned by IFeature::GetFaces.

2. eq.swp Edgar’s 46 line solution locates and selects the exact edges necessary for mating by considering the order in which the edges were returned in certain arrays.

3. rb.swp Raghvendra’s macro, which comes out to 53 lines (discounting using a colon to place statements on the same line), traverses the feature tree while examining several criteria until the right faces for mating are found.

4. ik.swp At a mere 64 lines, Ivana’s macro represents a very efficient way to solve the problem without hard-coding feature names or the order in which desired entities appear in entity arrays.

5. cs.swp At 110 lines, Corey offers a straightforward use of geometry and topology traversal to solve the problem. This is similar to how I solved the problem, which you can see in kr.swp. Both of our solutions are largely unoptimized for minimal length but also have the advantage of being easier to read and understand.

Thanks again to everyone who took the time to enter our contest!

Did any of the techniques utilized stand out to you as particularly clever? Hopefully you can pick up some new programming tricks while looking over these submissions, just as I have.

Until next time,
Keith

Want to learn about future CADSharp.com contests and new content? Sign up for our newsletter.


Leave Comment