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/
]]>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.
]]>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.”
Went to the WI-IL SW Simulation user group meeting yesterday. Worth the trip. Details to follow.
]]>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:
|
| Hierarchy of dimension-related objects. |
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.DimensionSet 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
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.
]]>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.
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.
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.
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
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.
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:
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
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.
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
The two best things to bring to a gunfight: a gun, and a friend with a gun.
]]>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”).
| Message box indicating successful acquisition of BOM. |
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”.
Speak softly and carry a big stick. Some folks out there can take a punch much better than they can take an insult.
]]>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
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!
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.
]]>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!
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, age 2 weeks, poses with carp derby runner-up. |