Tick Talk on EsoxRepublic.com http://esoxrepublic.com/blog I suppose this means I'm famous Thu, 06 May 2010 17:32:02 +0000 http://wordpress.org/?v=2.8.4 en hourly 1 Blank Datums macro link updated to get latest version http://esoxrepublic.com/blog/2010/05/06/blank-datums-macro-link-updated-to-get-latest-version/ http://esoxrepublic.com/blog/2010/05/06/blank-datums-macro-link-updated-to-get-latest-version/#comments Thu, 06 May 2010 17:32:02 +0000 Administrator http://esoxrepublic.com/blog/?p=49 Some time ago, I had made minor adjustments to my “Blank Datums” macro.  The adjustments were to prevent crashing on later versions of SolidWorks.

The update has been out for some time, but I failed to update the link on the download page, so users still only had access to the old version 2.0.

The link has been updated.  If you have trouble, make sure you are running “BlankDatums2a.swp”, available for download at http://www.esoxrepublic.com/freeware/

http://esoxrepublic.com/blog/2010/05/06/blank-datums-macro-link-updated-to-get-latest-version/feed/ 0
Esox “Copy Custom Info” revived and updated guts http://esoxrepublic.com/blog/2010/05/01/esox-copy-custom-info-revived-and-updated-guts/ http://esoxrepublic.com/blog/2010/05/01/esox-copy-custom-info-revived-and-updated-guts/#comments Sat, 01 May 2010 13:07:17 +0000 Administrator http://esoxrepublic.com/blog/?p=46 You just never know how popular some things are until they break.  This apparently is true for my “Copy Custom Info” macro.  The macro seems to have stopped working for many SW 2010 users.

The macro is ancient, by API standards.  It is one of my first published macros, and was written in SW2003.  Judging by the code, I wrote it before I was aware of early binding.  Also, SW’s API has come a long way and there were many ways to streamline the code.

I was able to do away with much embarrassing sophomoric hacksmanship. Glad to get that behind me.  Most notable improvement is that the program no longer needs to make duplicates of the files it is copying from (do not judge, I had my reasons!).  Assemblies and drawings selected for copying will open much faster.

The interface is about the same.  The only visible improvement will be in the preview windows.  There will be some indication that this is the SW2009 version.

The program will be posted on EsoxRepublic.com in the coming week.  Notices to be placed in popular forums that your less-popular author frequents.

http://esoxrepublic.com/blog/2010/05/01/esox-copy-custom-info-revived-and-updated-guts/feed/ 1
Word of the Day: “Concinnity” http://esoxrepublic.com/blog/2008/11/06/word-of-the-day-concinnity/ http://esoxrepublic.com/blog/2008/11/06/word-of-the-day-concinnity/#comments Thu, 06 Nov 2008 14:29:30 +0000 Administrator http://esoxrepublic.com/blog/2008/11/06/word-of-the-day-concinnity/ 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.

http://esoxrepublic.com/blog/2008/11/06/word-of-the-day-concinnity/feed/ 1
Shapeshifting Through SW Dimension API http://esoxrepublic.com/blog/2008/10/21/shapeshifting-through-sw-dimension-api/ http://esoxrepublic.com/blog/2008/10/21/shapeshifting-through-sw-dimension-api/#comments Tue, 21 Oct 2008 17:43:17 +0000 Administrator http://esoxrepublic.com/blog/2008/10/21/shapeshifting-through-sw-dimension-api/ 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.

http://esoxrepublic.com/blog/2008/10/21/shapeshifting-through-sw-dimension-api/feed/ 0
Reliable Sources of News re: Economic Crisis http://esoxrepublic.com/blog/2008/10/10/reliable-sources-of-news-re-economic-crisis/ http://esoxrepublic.com/blog/2008/10/10/reliable-sources-of-news-re-economic-crisis/#comments Fri, 10 Oct 2008 17:12:50 +0000 Administrator http://esoxrepublic.com/blog/2008/10/10/reliable-sources-of-news-re-economic-crisis/ 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.

http://esoxrepublic.com/blog/2008/10/10/reliable-sources-of-news-re-economic-crisis/feed/ 0
“ShellExecute” to Open a File in Its Default App http://esoxrepublic.com/blog/2008/09/26/shellexecute-to-open-a-file-in-its-default-app/ http://esoxrepublic.com/blog/2008/09/26/shellexecute-to-open-a-file-in-its-default-app/#comments Fri, 26 Sep 2008 15:35:07 +0000 Administrator http://esoxrepublic.com/blog/2008/09/26/shellexecute-to-open-a-file-in-its-default-app/ 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()
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”.

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.

http://esoxrepublic.com/blog/2008/09/26/shellexecute-to-open-a-file-in-its-default-app/feed/ 0
SW BOM to Excel Macro http://esoxrepublic.com/blog/2008/09/11/sw-bom-to-excel-macro/ http://esoxrepublic.com/blog/2008/09/11/sw-bom-to-excel-macro/#comments Thu, 11 Sep 2008 13:54:14 +0000 Administrator http://esoxrepublic.com/blog/2008/09/11/sw-bom-to-excel-macro/ …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.

http://esoxrepublic.com/blog/2008/09/11/sw-bom-to-excel-macro/feed/ 0
AllAPI lives http://esoxrepublic.com/blog/2008/08/29/allapi-lives/ http://esoxrepublic.com/blog/2008/08/29/allapi-lives/#comments Fri, 29 Aug 2008 14:37:50 +0000 Administrator http://esoxrepublic.com/blog/2008/08/29/allapi-lives/ 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
http://esoxrepublic.com/blog/2008/08/29/allapi-lives/feed/ 0
R.I.P. AllAPI.net http://esoxrepublic.com/blog/2008/08/28/rip-allapinet/ http://esoxrepublic.com/blog/2008/08/28/rip-allapinet/#comments Thu, 28 Aug 2008 14:54:52 +0000 Administrator http://esoxrepublic.com/blog/2008/08/28/rip-allapinet/ AllAPI.net. Unfortunately, that article has turned into an obituary.]]> 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.

http://esoxrepublic.com/blog/2008/08/28/rip-allapinet/feed/ 0
Ghosts of Configurations Past http://esoxrepublic.com/blog/2008/08/20/ghosts-of-configurations-past/ http://esoxrepublic.com/blog/2008/08/20/ghosts-of-configurations-past/#comments Wed, 20 Aug 2008 15:01:42 +0000 Administrator http://esoxrepublic.com/blog/2008/08/20/ghosts-of-configurations-past/ 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.
http://esoxrepublic.com/blog/2008/08/20/ghosts-of-configurations-past/feed/ 1