Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Free Macro: Creates Four Isometric Views

879 views
Skip to first unread message

Mike J. Wilson

unread,
Dec 20, 2001, 5:48:39 AM12/20/01
to
Due to popular demand, I decided to write a macro that will
create four isometric views in the "View Orientation" dialog
box. They are as follows...

ISO Front-Right
ISO Right-Rear
ISO Rear-Left
ISO Left-Front

Simply run the macro and your ready to go.

Notes:

*) This macro can be played at any time in an assembly or part

*) You can run the macro with the "View Orientation" dialog
box open, however, you must close it and re-open it to
see the new views.

*) As your assembly or part changes in size, you can "reset"
the four iso views by deleting them and running the macro
again. The macro will do a zoom-to-fit, allowing you to
see the whole model.

*) Can be used with Animator to rotate your model


You can download the macro here...
http://www.mikejwilson.com/solidworks/api-macros/isoviews.zip


Or if you prefer, you can use this code...

' *************************************************************
' ISOViews.swp - macro recorded on 12/20/01 by Mike J. Wilson
' *************************************************************
' Special thanks to Dennis Kelley and Dan Hanger for tips

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object

Sub main()

Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc

pi = 4 * Atn(1)
Z = Tan(30 * pi / 180)
X = Atn(Z / Sqr(-Z * Z + 1))
Y = -45 * pi / 180

Part.ShowNamedView2 "*Front", -1
Part.ActiveView().RotateAboutCenter X, Y
Part.ViewZoomtofit
Part.NameView ("ISO Front-Right")

Part.ShowNamedView2 "*Right", -1
Part.ActiveView().RotateAboutCenter X, Y
Part.ViewZoomtofit
Part.NameView ("ISO Right-Rear")

Part.ShowNamedView2 "*Back", -1
Part.ActiveView().RotateAboutCenter X, Y
Part.ViewZoomtofit
Part.NameView ("ISO Rear-Left")

Part.ShowNamedView2 "*Left", -1
Part.ActiveView().RotateAboutCenter X, Y
Part.ViewZoomtofit
Part.NameView ("ISO Left-Front")

End Sub


If anyone has suggestions or improvements,
let me know!

Mike Wilson

PS: Special thanks to Dennis Kelley and Dan Hanger
for tips.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
Check out our new Unlimited Server. No Download or Time Limits!
-----== Over 80,000 Newsgroups - 19 Different Servers! ==-----

Mark R

unread,
Dec 20, 2001, 10:43:35 AM12/20/01
to
> If anyone has suggestions or improvements,
> let me know!

This is one I already had that does basically the same thing. I don't
know if this is an improvement, but there's less math up front. The
views are named differently, and I delete them if they exist before
trying to re-create them.

' ******************************************************************************
' macro recorded on 10/26/01 by mreimer
' ******************************************************************************


Dim swApp As Object
Dim Part As Object

Dim View As Object

Sub main()

Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc

'delete existing views with these names if they exist
Part.DeleteNamedView ("Right Isometric")
Part.DeleteNamedView ("Rear Isometric")
Part.DeleteNamedView ("Left Isometric")

'Set the view to the standard Isometric view
Part.ShowNamedView2 "*Isometric", -1

' Get the view object
Set View = Part.ActiveView

'rotate the view, zoom to fit and save the view with the appropriate
name
View.RotateAboutAxis Atn(1) * 2, 0, 0, 0, 0, 1, 0
Part.ViewZoomtofit2
Part.NameView "Right Isometric"

'rotate the view, zoom to fit and save the view with the appropriate
name
View.RotateAboutAxis Atn(1) * 2, 0, 0, 0, 0, 1, 0
Part.ViewZoomtofit2
Part.NameView "Rear Isometric"

'rotate the view, zoom to fit and save the view with the appropriate
name
View.RotateAboutAxis Atn(1) * 2, 0, 0, 0, 0, 1, 0
Part.ViewZoomtofit2
Part.NameView "Left Isometric"

'Set the view to the standard Isometric view
Part.ShowNamedView2 "*Isometric", -1
Part.ViewZoomtofit2

End Sub

bbrazeau

unread,
Dec 20, 2001, 10:46:45 AM12/20/01
to
Greetings,
If more solidworks users were like you, and shared their ittelectual
property on this forum the solidworks community as a whole would
prosper enormously.You should submit this macro to solidworks for
inclusion in the model library!

Thank You,Sincerly,Brian Brazeau
> Mike Wilson
>
> PS: Special thanks to Dennis Kelley ,Dan Hanger and Mike Wilson
> this macro!

Mike J. Wilson

unread,
Dec 20, 2001, 1:24:33 PM12/20/01
to
Hi Mark,
I like your suggestion about deleting any existing views
before they are created. As far as your approach using...

View.RotateAboutAxis Atn(1) * 2, 0, 0, 0, 0, 1, 0
I found that I couldn't get it accurate enough. If you open
this part...
http://www.mikejwilson.com/misc/text-cube.zip
and zoom in on the center, you will see all of the lines
meet exactly in the center of the part. The only way I
found to achieve this was with the equations.
I noticed that the standard SolidWorks iso view
does not meet at the center when zoomed-in. It matches
your method. Is this because SolidWorks is not being
accurate enough, or is that the way an iso view is
supposed to be?

Regards,
Mike Wilson

Kandor

unread,
Dec 20, 2001, 12:28:06 PM12/20/01
to
Thanks Mike!

"Mike J. Wilson" <mwi...@sigmathree.com> wrote in news:3c21b445_1
@news.newsgroups.com:

Paul Charbonneau

unread,
Dec 20, 2001, 1:52:18 PM12/20/01
to
bbra...@adelphia.net (bbrazeau) wrote in message news:<908e993b.01122...@posting.google.com>...


Pardon my lack of experience with macro's but I tried running the .swp
file as well as copying the information you provided into a new .swb
and tried running that and got an error that would not let me
continue. (Error 168 in Line 14:Encountered: end of line expecting:.
-> Part.DeleteNamedView ("Right Isometric")) Is something out of
sinc here? It sounds like a nice feature that should be included in
SWX.

Anyway, Thanks for any help

Paul

Stefan Berlitz

unread,
Dec 21, 2001, 2:29:33 AM12/21/01
to

"bbrazeau" <bbra...@adelphia.net> schrieb im Newsbeitrag
news:908e993b.01122...@posting.google.com...

> If more solidworks users were like you, and shared their ittelectual
> property on this forum the solidworks community as a whole would
> prosper enormously.You should submit this macro to solidworks for
> inclusion in the model library!

You may want to take a look at some of my (german commented)
macros at http://solidworks.cad.de/mm_index.htm oder
http://swtools.cad.de/ (both german and english).

The macros are usually written as an example how to code a
special task, but there are some "productive" macros also.

If I have a little spare time left I will try to comment them in english
too. And yes, I have submitted them to for model library, but as you
read in the other posts ...

Stefan

--
unofficial german SolidWorks helpsite
http://solidworks.cad.de
tools and programs for SolidWorks
http://swtools.cad.de

Mark R

unread,
Dec 21, 2001, 10:59:48 AM12/21/01
to
> Pardon my lack of experience with macro's but I tried running the .swp
> file as well as copying the information you provided into a new .swb
> and tried running that and got an error that would not let me
> continue. (Error 168 in Line 14:Encountered: end of line expecting:.
> -> Part.DeleteNamedView ("Right Isometric")) Is something out of
> sinc here? It sounds like a nice feature that should be included in
> SWX.
>
> Anyway, Thanks for any help
>
> Paul

Looks like you got an extra ")" at the end of that line somehow.
The line should read..

Part.DeleteNamedView ("Right Isometric")

Mark

Dan Podzimek

unread,
Dec 21, 2001, 11:23:01 AM12/21/01
to
Good Job Mike,

One thing that I would add at the end is to release the Objects that
you set at the beginning. Put these two lines just before your end
sub.
Set Part = Nothing
Set swApp = Nothing

Thanks for the nice little macro.
dp

"Mike J. Wilson" <mwi...@sigmathree.com> wrote in message news:<3c21b...@news.newsgroups.com>...

Mark R

unread,
Dec 21, 2001, 11:43:26 AM12/21/01
to
"Mike J. Wilson" <mwi...@sigmathree.com> wrote in message news:<3c221...@news.newsgroups.com>...

> Hi Mark,
> I like your suggestion about deleting any existing views
> before they are created. As far as your approach using...
> View.RotateAboutAxis Atn(1) * 2, 0, 0, 0, 0, 1, 0
> I found that I couldn't get it accurate enough. If you open
> this part...
> http://www.mikejwilson.com/misc/text-cube.zip
> and zoom in on the center, you will see all of the lines
> meet exactly in the center of the part. The only way I
> found to achieve this was with the equations.
> I noticed that the standard SolidWorks iso view
> does not meet at the center when zoomed-in. It matches
> your method. Is this because SolidWorks is not being
> accurate enough, or is that the way an iso view is
> supposed to be?
>
> Regards,
> Mike Wilson


I doubt that's how an isometric is supposed to be. I never noticed
that the standard SolidWorks Isometric view was slightly skewed like
that. My guess is that the standard SolidWorks isometric view has an
error in it and since my macro just rotates the SolidWorks Isometric
view to create the new views, the same problem is transferred to those
new views. I will use your method from now on.

I wonder if SolidWorks is aware of the problem or if they skewed it
slightly for a reason.

Mark

Mike J. Wilson

unread,
Dec 21, 2001, 1:40:45 PM12/21/01
to
Hey Stefan, how close did I get?
(http://solidworks.cad.de/mm_index.htm)

00. All macros in a file (except 09)
01. Delete all surface colors
02. Select mass of all model components
03. Start programs by macro
04. Use API calls in macros
05. Save all pages of a drawing as DXF
06. Fix all components in model
07. Measure texts enter
08. Copy document options
09. Fill out engineering drawing block
10. Feature list
Feature list as Excel solution
11. Automatically create center line crosses
12. German Visual basic 3 assistance file

Nice library!,
Mike Wilson

KKrebs

unread,
Dec 31, 2001, 12:01:55 PM12/31/01
to
Great Stuff!

BTW, Changing Part.ViewZoomtofit to Part.ViewZoomtofit2 (note the
2 on the end) will zoom in closer.


This function differs from ViewZoomtofit only in that it will zoom in closer
to the geometry and have less of a border.

Cheers,

Kevin R. Krebs
Plano, Texas


"StarrRider" <Starr...@Hotmail.com> wrote in message
news:moWX7.9417$dG.54...@news1.rdc1.sdca.home.com...
> Mike - I liked your macro so much that I messed with it (after reading all
> the rest of these messages and incorporating them)
> I added:
> Deleting the original views
> Releasing the variables
> Added the Other 4 (Bottom) Iso views
> Renamed the views
> TRF-ISO & BRF-ISO
> TRR-ISO & BRR-ISO
> Ect
>
> Thanks again
> StarrRider


>
> ' *************************************************************
> ' ISOViews.swp - macro recorded on 12/20/01 by Mike J. Wilson
> ' *************************************************************
> ' Special thanks to Dennis Kelley and Dan Hanger for tips
>
> Dim swApp As Object
> Dim Part As Object
> Dim boolstatus As Boolean
> Dim longstatus As Long
> Dim Annotation As Object
> Dim Gtol As Object
> Dim DatumTag As Object
> Dim FeatureData As Object
> Dim Feature As Object
> Dim Component As Object
>
> Sub main()
>
> Set swApp = CreateObject("SldWorks.Application")
> Set Part = swApp.ActiveDoc
>
> pi = 4 * Atn(1)
> Z = Tan(30 * pi / 180)
> X = Atn(Z / Sqr(-Z * Z + 1))
> Y = -45 * pi / 180
>

> Part.DeleteNamedView ("TRF-ISO")
> Part.DeleteNamedView ("TRR-ISO")
> Part.DeleteNamedView ("TLF-ISO")
> Part.DeleteNamedView ("TLR-ISO")
>
> Part.DeleteNamedView ("BRF-ISO")
> Part.DeleteNamedView ("BRR-ISO")
> Part.DeleteNamedView ("BLF-ISO")
> Part.DeleteNamedView ("BLR-ISO")


>
> Part.ShowNamedView2 "*Front", -1
> Part.ActiveView().RotateAboutCenter X, Y
> Part.ViewZoomtofit

> Part.NameView ("TRF-ISO")


>
> Part.ShowNamedView2 "*Right", -1
> Part.ActiveView().RotateAboutCenter X, Y
> Part.ViewZoomtofit

> Part.NameView ("TRR-ISO")


>
> Part.ShowNamedView2 "*Back", -1
> Part.ActiveView().RotateAboutCenter X, Y
> Part.ViewZoomtofit

> Part.NameView ("TLR-ISO")


>
> Part.ShowNamedView2 "*Left", -1
> Part.ActiveView().RotateAboutCenter X, Y
> Part.ViewZoomtofit

> Part.NameView ("TLF-ISO")
>
> Part.ShowNamedView2 "*Front", -1
> Part.ActiveView().RotateAboutCenter -X, Y
> Part.ViewZoomtofit
> Part.NameView ("BRF-ISO")
>
> Part.ShowNamedView2 "*Right", -1
> Part.ActiveView().RotateAboutCenter -X, Y
> Part.ViewZoomtofit
> Part.NameView ("BRR-ISO")
>
> Part.ShowNamedView2 "*Back", -1
> Part.ActiveView().RotateAboutCenter -X, Y
> Part.ViewZoomtofit
> Part.NameView ("BLR-ISO")
>
> Part.ShowNamedView2 "*Left", -1
> Part.ActiveView().RotateAboutCenter -X, Y
> Part.ViewZoomtofit
> Part.NameView ("BLF-ISO")


>
> Set Part = Nothing
> Set swApp = Nothing
>

> End Sub
>
>
>
>


Arlin Sandbulte

unread,
Dec 31, 2001, 3:42:18 PM12/31/01
to
BTW,

Anybody ever notice how the default ISO view in SWX is NOT A TRUE ISO view??

Do this to test it...
1.) Create a 1x1x1 cube (or any perfect cube)
2.) Use the hidden lines view
3.) Go to the default ISO view
4.) Zoom in to the center corner on the screen....
The Front and back vertexes should be EXACTLY coincident, which they are
NOT.

Another way to test this flaw..

1.) Create a 1x1x1 cube
2.) Insert an ISO view (the SWX default) into a drawing and use PROJECTED
dimensioning
3.) Sketch a horizontal line starting at the bottom vertex.
4.) Place an angular dimension between the horizontal line you just created
and the bottom edge of the cube
The angle should read EXACTLY 30 deg. It does not.......


"Stefan Berlitz" <stefan.berlitz@[nospam]solidworks.cad.de> wrote in message
news:3c22e4de$0$187$4d4e...@read.news.de.uu.net...

Evadem

unread,
Dec 31, 2001, 5:32:55 PM12/31/01
to
Comments below.
"Arlin Sandbulte" <arlinsa...@hotmail.com> wrote in message
news:3c30...@MAIL.mhogaming.com...

> BTW,
>
> Anybody ever notice how the default ISO view in SWX is NOT A TRUE ISO
view??
>
> Do this to test it...
> 1.) Create a 1x1x1 cube (or any perfect cube)
> 2.) Use the hidden lines view
> 3.) Go to the default ISO view
> 4.) Zoom in to the center corner on the screen....
> The Front and back vertexes should be EXACTLY coincident, which they are
> NOT.
>
> Another way to test this flaw..
>
> 1.) Create a 1x1x1 cube
> 2.) Insert an ISO view (the SWX default) into a drawing and use PROJECTED
> dimensioning
> 3.) Sketch a horizontal line starting at the bottom vertex.
> 4.) Place an angular dimension between the horizontal line you just
created
> and the bottom edge of the cube
> The angle should read EXACTLY 30 deg. It does not.......

It is only 29.997°, how could SWX be so sloppy.

Dave


Mike J. Wilson

unread,
Jan 1, 2002, 12:58:35 AM1/1/02
to
> > Anybody ever notice how the default ISO view in SWX is NOT A TRUE ISO
> view??

Read my reply to Mark on 12/20/2001 at 10:24am ;^) ...

Mike Wilson

0 new messages