Tick Talk on EsoxRepublic.com


Word of the Day: “Concinnity”

Posted in Uncategorized by Administrator on the November 6th, 2008

Got this in one of my daily Arcamax word-of-the-day emails…

concinnity \kuhn-SIN-uh-tee\ (noun) - 1 : Internal harmony or fitness in the adaptation of parts to a whole or to each other. 2 : Studied elegance of design or arrangement — used chiefly of literary style. 3 : An instance of concinnity.

Concinnity comes from Latin concinnitas, “elegance; harmony of style,” from concinnus, “well put together; pleasing, on account of harmony and proportion.”

SW Simulation (”COSMOS”) WI-IL user Group meeting

Went to the WI-IL SW Simulation user group meeting yesterday. Worth the trip. Details to follow.

Shapeshifting Through SW Dimension API

Posted in API by Administrator on the October 21st, 2008

One of the sticky things about working with SolidWorks API is the fragmented object structure. Often, it takes more than one object type to deal with a single object. The most common example is the ModelDoc/PartDoc/AssemblyDoc/DrawingDoc objects. All SW files are ModelDocs, but many API functions are only available in the type-specific objects, and accessing those functions may require setting a second PartDoc or AssemblyDoc or DrawingDoc object after the ModelDoc object is already set.

A less common but more convoluted set of objects is the ones that deal with dimensions. There are as many as four different objects that deal with a SolidWorks dimension:

  • Dimension: Properties and methods for the dimension parameter, such as name, value, driven state
  • Tolerance: A sub-object of Dimension, used to access tolerance info
  • Display Dimension: Dimesnions can be displayed in more than one place, DisplayDimension is a single display instance.
  • Annotation: DisplayDimension is a sub-object of the Annotation object. You would need the Annotation object to access layers and leaders.
Dimension object chart
Hierarchy of dimension-related objects.

Selecting Dimensions

When Accessing selected dimensions, the SW SelectionMgr object passes selected dimensions as DisplayDimension object. This means that it is necessary to pass the DisplayDimension object to a Dimension object to change its value. It would be necessary to pass the DisplayDimension to an Annotation object to change its layer. To change a tolerance, one may need to access the Tolerance object (though there are some unlisted Dimension object API’s that access tolerance data).

The example code below shows how to take a DisplayDimension from the SelectionMgr, pass it to a Dimension object, and then change the dimension value.

Set swApp = Application.SldWorks
Dim swApp As SldWorks.SldWorks
Dim ActDoc As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.SelectionMgr
Dim DispDim As SldWorks.DisplayDimension
Dim DimToEdit As SldWorks.Dimension

Set ActDoc = swApp.ActiveDoc
Set SelMgr = ActDoc.SelectionManager

‘get selected DisplayDimension object
Set DispDim = SelMgr.GetSelectedObject6(1)
‘pass selection to a Dimension object
Set DimToEdit = DispDim.GetDimension
change value of Dimension object
DimToEdit.SetUserValueIn2 ActDoc, CDbl(2.78), swSetValue_UseCurrentSetting

OT: Football pool

Once again, I’m in a football pool. Once again, I was off to an abysmal start, 4-5 right per week. Until last week, that is. I changed my pick strategy. For the last two weeks, I have picked the team whose home city has the highest crime rate. Got 10 right last week and 7 this week (our winner only had 9). I’ll go with this strategy for a while longer and see how it pans out.

Reliable Sources of News re: Economic Crisis

Posted in Uncategorized by Administrator on the October 10th, 2008

I have been following the current economic crisis long before it became news. I average two to three hours per week reading in-depth about the conditions that have brought this crisis to bear. After the last big crash, I took stock of my news sources to see who actually saw it coming. I promised myself I would pay heed when these same sources sounded the alarm again.

My sources did not fail me. I pulled my long term money from the stock market in November. Since then. I have made modest profits taking short term contrarian positions, while my coworkers’ 401k’s nose down, adding years to their projected retirement dates.

Where to go

My favorite dependable sources for news and information:

John Mauldin: John writes two blogs on Investor Insight: Outside the Box and Thoughts from the Frontline. These are not light reading. These are articles to print, study, and highlight. There is much to learn here

Bill Fleckenstein: I actually discovered “Fleck” just recently. A friend of mine who had exercised similar foresight told me this is where he got his “heads-up”. I’ve read many of his articles, his record speaks for itself. Fleck writes a free weekly blog on MSN money in addition to his subscription service.

Stratfor.com: I was fortunate to get in with Stratfor ten years ago while they had more free stuff available. I still get alerts and news via email from them. I don’t know how to get on their list, but if you can… SCORE! It was Stratfor that introduced me to John Mauldin.

Schaeffer Research: If you’re looking for a good base to start learning about contrarian investing, this is a good place to start. They’re pretty aggressive about trying to sell their wares. Ignore that and dig into the content. Even in tough times, it is possible to make money.

Soundbites and News Reveal Nothing

By now, only complete idiots believe the mainstream news media provides fair, balanced, accurate coverage. Also worth bypassing are left- and right-wing partisan commentators. Most of the talking heads are too lame to understand the nature of the current climate, anyhow. The situation is too complicated for blurbs. To understand requires study.

The Crisis Hits Main Street in the Midwest

For those who believe this is only the problem of in-over-their-head mortgage holders and Wall Street fat cats, think again. 401K’s are getting sapped. Insurance and pension funds, too. What’s more important, the credit crunch is hurting business.

I heard from one business owner that he is losing orders because his customers can not get credit. They are good customers in a growth industry. As inventory piles up, so will the ranks of the unemployed.

Another business (one that I have a personal financial stake in) is having similar problems. They manufacture capital production equipment. Customers are pushing timelines back while they search for financing

The best two paragraphs I have read

Below is an excerpt from a Stratfor email I received recently. It is the best synopsis I have read.

As interest rates declined in recent years, investors — particularly conservative ones — sought to increase their return without giving up safety and liquidity. They wanted something for nothing, and the market obliged. They were given instruments ultimately based on mortgages on private homes. They therefore had a very real asset base — a house — and therefore had collateral. The value of homes historically had risen, and therefore the value of the assets appeared secured. Financial instruments of increasing complexity eventually were devised, which were bought by conservative investors. In due course, these instruments were bought by less conservative investors, who used them as collateral for borrowing money. They used this money to buy other instruments in a pyramiding scheme that rested on one premise: the existence of houses whose value remained stable or grew.

Unfortunately, housing prices declined. A period of uncertainty about the value of the paper based on home mortgages followed. People claimed to be confused as to what the real value of the paper was. In fact, they were not so much confused as deceptive. They didn’t want to reveal that the value of the paper had declined dramatically. At a certain point, the facts could no longer be hidden, and vast amounts of value evaporated — taking with them not only the vast pyramids of those who first created the instruments and then borrowed heavily against them, but also the more conservative investors trying to put their money in a secure space while squeezing out a few extra points of interest. The decline in housing prices triggered massive losses of money in the financial markets, as well as reluctance to lend based on uncertainty of values. The result was a liquidity crisis, which simply meant that a lot of people had gone broke and that those who still had money weren’t lending it — certainly not to financial institutions.

“ShellExecute” to Open a File in Its Default App

Posted in API by Administrator on the September 26th, 2008

To introduce using Windows API in macros, I picked the simplest example I have in my toolbox: opening a file in its default application. Using the ShellExecute command, one can call a file to simply open in its default application, much the same way that double-clicking a file icon in an explorer window would do. I use it to add hyperlinks to my website in my published macros.

The “Declare” Statement

To use a Windows API function in a SolidWorks macro, one must first add the function to the macro code using a Declare statement. A declare statement acceesses and names a function in a Windows DLL library for use in VB code. Elements of a Declare statement are thus:

  • Name of function or sub
  • “Lib: name of DLL library containing function or sub
  • “Alias”: a user-defined alternate name for the function
  • function parameters
  • Return variable

An example of the declare statement for ShellExecute would look like this:

Public Declare Function ShellExecute
Lib “shell32.dll” _
Alias “ShellExecuteA”
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long

Using ShellExecute for Hyperlink

To make a hyperlink, I use ShellExecute to open a web page. The user’s operating system determines the default application with which to open the web page.

Public Sub OpenEsoxWeb()
ShellExecute 0, vbNullString, “http://www.EsoxRepublic.com”, vbNullString, “C:\”, SW_SHOWNORMAL
End Sub

Connect the OpenEsoxWeb sub to an object in a form to give that object a “hyperlink”.

Private Sub lblWebLink_Click()
OpenEsoxWeb
End Sub

You can find an implementation of this in my Delete Custom Info macro.

Works with any file

Use ShellExecute with any file you want to open: web pages, MS Word, Excel, or PowerPoint Docs, images. Wherever you need the effect of a “double-click”.

Links:
AllAPI.net archive on Mentalis.org
The Borg

Thought for the day

The two best things to bring to a gunfight: a gun, and a friend with a gun.

SW BOM to Excel Macro

Posted in API, Esox Software by Administrator on the September 11th, 2008

…not quite, but a fast way from here to there.

I just released a macro I have been using for a few months. “Copy BOM to Clipboard” macro does exactly what it says: it copies a table-style BOM from a SW drawing to the clipboard in a format that can readily be pasted into MS Excel. Download here.

Just run the macro with a SW drawing open. If successful, there will be a message like that shown below. Then go to an Excel worksheet, select a cell, and paste (”ctrl-v”).

BOM to Clipboard message window
Message box indicating successful acquisition of BOM.

Developer’s notes

It’s been a while, but I am trying to remember some of the specific challenges of writing this. It took about two hours of fumbling until the error-to-trial ratio dropped below 1.0.

Application writing is often mostly about validation. Checking to see if there is an active document, is it a drawing, does it have a BOM (or more than one). That took most of the time.

There was a hook to getting ahold of the table data. I put the BOM data first into a SldWorks.BomTableAnnotation object, then moved it to a SldWorks.TableAnnotation object which could then be parsed into an array. The final array is then written to a tab-delimited string which pastes so nicely into Excel.

It could have been more elegant, but it “works fine, lasts long time”.

Thought for the day

Speak softly and carry a big stick. Some folks out there can take a punch much better than they can take an insult.

AllAPI lives

Posted in API by Administrator on the August 29th, 2008

Long live AllAPI.

Yesterday I reported that AllAPI.net was gone. The domain is gone, but the site lives on. It has moved to http://allapi.mentalis.org/. This is my go-to site for Windows API snippets.

Also recommended: codetoad.com. My registry utilities VBA code module came from here.

In upcoming weeks, I will be discussing using Windows API to enhance VBA macros with functions like

  • “Save” and “Open” dialogs
  • Folder browsing dialogs
  • File security
  • Registry tools

R.I.P. AllAPI.net

Posted in API, Uncategorized by Administrator on the August 28th, 2008

I was gearing up for a set of articles on using Windows API in macros. I was going to lead off with a brief article about one of my favorite resources, AllAPI.net. Unfortunately, that article has turned into an obituary.

For years, AllAPI.net was my first stop for Windows API help. I first discovered it in 2003. Already, the site had been relegated to archive status, available but no longer updated. Still, it was an indispensible resource for adding Windows API functions to code.

I’m verklempt. I’m lost. I don’t know where to go, now. If anyone has links to good online Windows API examples, I would appreciate a heads-up!

Windows API to extend macro functionality

Often, questions come up about adding certain functions to a SolidWorks macro. File open/save and folder browsing are the most popular. Since the dialog objects for these tasks are not licensed to VBA, one must take a backdoor approach via Windows API. I also use Windows API for Windows file security, registry functions, and opening documents.

Ghosts of Configurations Past

Posted in Software by Administrator on the August 20th, 2008

Sometimes I’m more entymologist than engineer. I’m always discovering new bugs.

I’m working with a layout sketch (SW 2007 SP 4) that functions as a schematic for a lift mechanism. There are multiple configurations for different phases of the lift.

There was one dimension for a line length that changed between configurations, with both driven/driving states and length changing at different phases of the lift sequence. Recently, we changed this dimension to be a single driving value for all configurations.

We also deleted some old configs and added some new ones. That’s when the fun started. The dimension was set to 6.670 for all configs. Every time a new config is created, the dimension reverts to its old value (6.668) and becomes config-specific for the new config. Seems the “All configurations” setting for the value isn’t sticking when new configs are created, and SW is somehow remembering what the old value was and applying that to the new config!

Upcoming topics

  • Adding “Save” and “Open” dialogs to SW macros
  • Intro to SW object events
  • How to swap and copy components as they load
  • Sketch-based 4-bar linkage design
  • Photos of wind farm construction near Fond du Lac, WI

Vacation and Hingham Carp Derby

I took a week off. Couldn’t afford to go anywhere, w/ gas prices and expenses from recent family addition. I did manage to golf 9 holes per day and introduced myself and my fly rod to a multitude of smallouth bass in the Sheboygan River.

Aug.2 was the Hingham Pond Carp Derby, and annual event in my adopted hometown. I worked as a volunteer, shuttling for ice and setting up tables. I did take the time to take a picture.

Falco w/ carp derby runner-up
Falco, age 2 weeks, poses with carp derby runner-up.

New SolidWorks Where-Used Tool

Posted in Esox Software by Administrator on the August 7th, 2008

EsoxRepublic.com has released a new where-used tool for SolidWorks. This new stand-alone application was created to fill in a gap caused by the undependability and inflexibility of the Windows Indexer-driven SW Explorer where-used search.

Annotated screen shot of Esox Republic's Where-Used tool
Annotated screen shot of main interface of Esox Republic’s newly-released Where-Used application. (Click image to enlarge.)

Succeeds where SW Explorer fails

As with most of Esox Republic’s freeware, this one was born from necessity. In many cases, SW Explorer was not finding all where-used references when performing rename, replace, and Pack-and-Go.

The main reason for SW Explorer’s failure in where-used searches is that SW Explorer relies on Windows Indexing for its searches. Windows Indexing provides a list of files and references to SW Explorer. More often than not, that list is incomplete. This is especially true for netwotk folders.

Also, SW Explorer does not allow one to tailor the where-used search. One can not add or remove folders from the search area, nor can one specify reference types or file types searched. Esox Republic’s Where-Used tool can do these things.

Esox Republic’s Where-Used application is driven by SW API’s Document Manager object. The SWDM performs a “hard-target, house-to-house” search of all files for its where-used searches. The result is the most current where-used results possible.

The downside is that it is a bit slow. Checking files takes much more time. Still, if accuracy and flexibility are more important, here’s your tool. The program is available only as an .exe, due to SWDM licensing requirements.

Search results
Search results

Other news…

Birth announcement

There’s a new member of Tick’s clan. Falco William Henry was born July 15, 7 lb. 6 oz., 3rd of 3 boys.

Thanks Matt & Matt

Thanks to Matt Lombard and Matt Lorono (SolidWorks Legion) for including links to my blog into theirs. Naturally, I will be returning the favor.

SW Coordinate Systems Are Nearly Useless

Posted in Uncategorized by Administrator on the July 30th, 2008

Coordinate Systems in SolidWorks have been a disappointment from the beginning. Like a freshman congressman, they have little purpose but to wait around, be present and hope for greater possibilities as they gain seniority. Unlike said congressman, coordinate systems are just not gaining any power.

SW Help’s own description of coordinate systems’ limited utility is embarassingly anemic:

You can define a coordinate system for a part or assembly. Use this coordinate system with the Measure and Mass Properties tools, and for exporting SolidWorks documents to IGES, STL, ACIS, STEP, Parasolid, VRML, and VDA.

That’s missing a whole universe of potential usefulness, especially compared to what UG, Pro/E, and even AutoCAD(!) can do with their coordinate systems (”CSYS”).

Back in my Pro/E days, I would create a user-defined CSYS to use as the main anchor for locating part geometry. That way, I could move and rotate an entire part w.r.t. the universal CSYS simply by redefining one feature. This was very useful when making models for customers that required “in-place” designs (”in-place” = line up origins of parts to locate in master assembly).

That’s what I miss the most. But, there’s plenty more. Here’s a partial wish list of what SW can’t do w/ coordinate systems that other programs can:

  • Define and update view orientations
  • Mates: SW CSYS’s are truly impotent, for they can not mate.
  • Define datum planes and axes. (Add to this that SW has no control over which side of a datum plane is the front.)
  • Sketch relations: Can not constrain sketch entities parallel/perpendicular/coincident to CSYS axes or origin. This would be especially handy in 3D sketches.
  • Move or copy geometry: it would be wonderful to be able to use a CSYS transform to define how geometry is moved or copied.

Painful Workarounds

Meanwhile, I have resorted to second-rate workarounds to get me by. Sometimes a 2D or 3D sketch can stand in for a CSYS. At least then I can make sketch references and create planes. Still, very inelegant. No workaround in sight for view orientation. A macro could do this, but I haven’t written one yet.

Speaking as the “High Priest of the Temple of Unused Potential”, I beg you, SolidWorks, please do something with this!

Next Page »