Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Instant Measure 10

Status
Not open for further replies.
Shoot, I knew there was something I was forgetting. I need to figure out how to put that into an .ini file or something since the .dll isn't editable. GetCurrentMacroPathName doesn't seem to work from the .dll.

-handleman, CSWP (The new, easy test)
 
handleman,
That is so way cool. Another star for you.


Standing
SolidWorks Pro 2009 x64, SP3.0
PDMWorks Workgroup, SolidWorks BOM,
HP xw8600, 64-bit Windows Vista Business, Service Pack 1
Intel Xeon CPU, 3.00 GHz, 16 GB RAM, Virtual memory 166682 MB,
nVidia Quadro FX 4600
 
If you're thinking of using an .ini file to store settings, consider using registry entries instead.
 
When you state to change it to "SW VSTA Macros (*.dll)" how and what are we changing. New at this so more help would be great.

Thanks in advance
 
The VSTA macros only work on 2009, so if you're running something earlier than that it won't work. If you are on 2009, go to Tools->Macro->Run. It will bring up a dialog box to browse for files. Change the file type filter in that dialog to "SW VSTA...." and browse to wherever you put the unzipped .dll files. Choose SmartMeasure.dll.

-handleman, CSWP (The new, easy test)
 
handleman,
I had it working just fine on Friday. Today, not so good.
Today I get:
Run-time error '91':
Object variable or With block variable not set

Then clicking Debug I get the following:
Macro stopped at CallListener

Code:
Dim Listener As New MyListeningClass
Sub main()

Listener.Connect2SW

End Sub

In the SolidWorks icon I have:
"C:\Program Files\SolidWorks Corp\SolidWorks\SLDWORKS.exe" /m "C:\Program Files\SolidWorks Corp\SolidWorks\Macros\SmartMeasure.swp"

Do you have any ideas as to what I am doing wrong?


Standing
SolidWorks Pro 2009 x64, SP3.0
PDMWorks Workgroup, SolidWorks BOM,
HP xw8600, 64-bit Windows Vista Business, Service Pack 1
Intel Xeon CPU, 3.00 GHz, 16 GB RAM, Virtual memory 166682 MB,
nVidia Quadro FX 4600
 
That's a tough one to debug. I'm guessing that the real error is happening somewhere inside the MyListeningClass. The VBA debugger often has problems highlighting the actual error when it's inside a form or class.

You may want to try the VSTA version. It does have more features than the VBA one. Here's the source for it, since it doesn't programmatically change precision. There are two constants ANGDEC and DISTDEC at the top of the MeasureClass to set the number of decimal places.



-handleman, CSWP (The new, easy test)
 
 http://files.engineering.com/getfile.aspx?folder=2d7c3194-9fa8-47cf-8a27-648757992e33&file=SmartMeasure.zip
Dissymmetry,

About the VBA version you updated for 2009...should it work for 2008 if I re-map the references?

I am getting an error and don't understand what call is the culprit.

Thanks,
Ken
 
Using SW 09 and I downloaded the zip file for smartmeasure, now I changed the properties in the icon that starts SW with
"C:\Program Files\SolidWorks Corp\SolidWorks\SLDWORKS.exe" /m "C:\Program Files\SolidWorks Corp\SolidWorks\Macros\SmartMeasure.dll"

Why is it I still have to execute the macro through the tools menu? I have the dll's in the directory as described in the above. Puzzled in Milwaukee.
 
DOH! ShowSmartMessage doesn't exist until SW2009 (I think).

I already took Dissymmetry's version and modified it a little bit. I changed the number of decimals to 8, but set it to drop trailing zeros (my personal preference). Since I took the time to change it already, I figured I would pass it on if anyone else was interested. You'll have to update the References to SW2009, but hopefully it will work after that.

Later,
Ken
 
 http://files.engineering.com/getfile.aspx?folder=c8d45afc-6318-457c-813b-f1de5185664f&file=SmartMeasure_DropTrailingZeros.swp
Ken,
I hate for you to have done that work for nothing! Here's a version that works for 2008. It uses a callout rather than a SmartMessage. The callout looks exactly the same as the SmartMessage except it appears a little bit farther away from the cursor and it has a leader on it. I still have 2008 installed, so I tested and it works.... sort of:

I don't think you're going to like the results from your trailing zero removal routine... It removes the zeros from 100 and leaves you with 1. :)

I've included the text from my current VSTA version if you want to take a look at it. I think the end result of the VSTA version is going to be what you want as long as you change the constant at the top for precision. It currently rounds to the whatever precision is specified in the constants, but it does drop trailing zeros after the decimal. Rounding is indicated by an ellipsis(...). There were a couple of bugs in the version you had regarding different combinations of selections, etc. Also, the angle (in radians) was being reported by Measure to 8 decimals, but the conversion factor was a full double. That meant that it thought the angle was always being rounded off, and a true 90° was being. reported as 90.000000...°.

I wish I had time to back-convert the full VSTA version to VBA. Sorry!



-handleman, CSWP (The new, easy test)
 
 http://files.engineering.com/getfile.aspx?folder=d2cd7d47-452a-429d-b015-86e9535b7e9d&file=SmartMeasure2008.zip
I'll work on a back-to VBA version of what you have. I'd like to incorporate the changes you've made, but I'm going to stay with VBA so I can make my own edits easily. =P I'll post it when it's done.

I've got a lot of jobs on my desk, so it may be a bit before I get back to it.
 
Attached is version VBA 2.0a

' Changelog:
' Rev 0.2a
' - Now pulls conversion and unit strings from the current Document units settings.
' - Moved unit conversion and identification inside measure it. If user changes document settings
' after macro is started, now will keep current with document settings.
' Rev 0.2
' - Added ANGSF to convert angle units
' - Added DISTDEC to control displayed precision for linear units
' - Added DISTSYM to pull displayed linear unit symbol from document unit selection
' - Added ANGDEC to control displayed precision for angle units
' - Added ANGSYM to pull displayed angle symbol from document unit selection
' - Added all unit conversions
' - Added format control through FixNumFmt()
' - FixNumFormat also replaces IndicateRound() and now uses "..." instead of "*"
' Rev 0.1c
' - Added MESSAGETIME to allow easier control of tooltip display time
' - Fixed discrepancy in display value for coplanar planes.
' Rev 0.1b
' - Fixed ToolTip not showing
' - Fixed non-display of non parallel entities where normal dist and sit are equal
' - Added feature (set using UFIX constant) to round units to fixed size.
' Rounded values display with an asterisk following the value (IndicateRound Function)


Sorry it's still VBA but it should be very easy to update the vsta version from this code.


 
 http://files.engineering.com/getfile.aspx?folder=8b56137b-92ce-402c-8f34-90f0defe0c66&file=SmartMeasure_VBA_0.2a.swp
One thing I noticed the VBA version is not doing is showing the information of a single entity like the vsta version does. I must have missed something or not had all the code?
 
You might want to look at the VBA version I uploaded in response to Ken, which uses the callout rather than a SmartMessage. Using the callout extends the usability to 2008. If you really wanted to get fancy, you could detect which version is running and decide which to use.

The reason it's not doing the single-pick stuff is that the event handlers for selection change originally (and currently on your VBA code) only call MeasureIt when the number of selections is 2. The VSTA version calls MeasureIt when there are either 1 or 2 selections.

Not sure why it's not showing the tooltip. It's not showing on my machine either.

-handleman, CSWP (The new, easy test)
 
Yea I fixed the single pick issue in 0.2c

Take a look at the unit conversion method I used, you might like it better than what you have in your current file.

Have a great weekend!
 
Handleman,

Thanks for all the valuable info...YET AGAIN! I back-converted your Vista Version to SW2008-VBA. It is attached for anyone else out there stuck in SW2008 :)

To the VBA version, I included:
-Your "Callout" recommendation
-Got the trailing zero removal routine working correctly
-Added functionality to unload the Class...just run the macro a second time and it'll unload if the "swSecession" object already exists.

Thanks again for all the help.
Ken
 
 http://files.engineering.com/getfile.aspx?folder=794308c5-c6f9-4c93-bf2a-29d4fac2c8c0&file=SmartMeasure2008.swp
Status
Not open for further replies.
Back
Top