How many of you are familiar with Python? Those of you who are, did you know it is pretty much a no-brainer to use it
to script Solidworks through COM with the win32 extensions from Mark Hammond? This means super-easy scripting of
the API, and with the use of wxPython (the windowing toolkit) you can do full-on GUI stuff just as easy.
Why, you may ask? Well, first of all - it is totally free (Open Source). Secondly, it is 100% interpreted, so you can make
a change to your GUI application, with no need to re-compile, re-install, whatever, just hit Go! (Actually, you can even
compile Python into .exe's if you want to as well). I have a few programs I wrote in VB a long time ago (the obligatory
Custom Properties, and a batch file converter) and some macros I am porting over to Python. I just started tonight, and
I must admit I don't know much about COM. I have a couple small issues yet to figure out, but I am already talking to
Solidworks with Python. I think this would be a awesome outlet for people who may not be "programmers" to do some
pretty powerful stuff.
If there is interest, I will try and help out as many people as possible in the days to come - provided they can help me out
as well. I would like to think I am pretty darn handy with Python, but when it comes to COM I am not. Luckily, once this
is working, the COM part of it just goes away, and you never see it.
Anyway, post if you are interested (especially if you are currently using Python with Solidworks), and let's have some
fun! If you don't know what Python is - check out www.python.org. Download it, and go through the tutorial. It is the
easiest (and best) programming language on the planet (well, most of us think so...).
Markus.
That look very intresting. Could you keep us informed. It would make the
transition to Linux more easier. :)
--
Dale Dunn
Design Engineer
www.jamestool.com
Well, I think the biggest reason (of many) is simply the ease and elegance of the language. I have tried to explain it
before, but the best thing is to try it for yourself (aw shit....I sound like JB...sorry). I DO have examples I could send
people, but you need to install Python first.
We use it at work (pure software development - nothing to do with CAD or Solidworks) for rapid prototyping, but are
finding that we are writing complete apps in it with ease. I talked to one developer at a games company who said they
are using Python for everything but the most complex graphics in their games now, and their codesize is sitting around
65% of the size of an equivalent game written in C++.
Anyway, simply put it is an elegant language, with beautiful syntax that most people find the best out there. There are
others who don't like it for exactly the reasons some people do like it. The biggest "preferential" barrier is that it is a
dynamically typed language. This means no declaring of variables. And you can reassign a variable to something
totally different later. It is similar to Java in that there is no memory management - garbage collection is done for you.
You don't have to destroy objects, maintain reference counts, etc. You just need to worry about programming. If you
aren't careful, you can pass the wrong type to a function however, and then if you try to iterate over a single integer
when you were expecting a list, and you don't catch the exception....well - then that's not good progrsmming anyway in
my opinion.
Finally - everyone I have spoken to (including myself....yes, I talk to myself) - when they tried it for the first time were
absolutely astounded that that the first *real* program they wrote "worked" the first try. The language is so natural and
easy.
I'll try to get some time to post some meaningful examples. Using CAD is my evening job, so I'll have to do what I can in
the evenings. I'll try to keep up with the newsgroup during the day.
And yes, it is completely cross-platform (much better then Java in this respect in my experience), so when Solidworks
does move to Linux.....hehe.
--
Markus.
I would be delighted when you could send me some examples. Today I
installed the Python on Windows and have it already at home on Linux.
Johnny Geling
johnny.gelin...@chello.be
I downloaded it last night and tried the tutorial a little bit. I have been
wanting to get into doing programs for SW but I have no experience at it. VB
was greek to me but so far Python seems pretty easy to learn. I would really
appreciate some examples too.
I only have one question. Where are the movies on their site? ;-)
Dave
unfortunately, i'm still struggling with PHP, and am not about to take on
another language at the moment. :)
regards,
nick e.
Markus Wankus wrote:
> Hi All.
>
> How many of you are familiar with Python? Those of you who are, did you
> know it is pretty much a no-brainer to use it
> to script Solidworks through COM with the win32 extensions from Mark
> Hammond? This means super-easy scripting of the API, and with the use of
> wxPython (the windowing toolkit) you can do full-on GUI stuff just as
> easy.
> Markus.
--
======================
Support Solidworks for Linux.
Go to http://www.cadsense.co.nz/SWXwish.htm
search for Linux and vote! It's currently #14!!
======================
Well, PHP is cool. One of the first *cool* languages I found. But Python is cooler! And much easier to learn....
Markus
Well, last night I figured things out (with some help - Open Source is great...), and it all seems to be working properly
now. Quoting the guru who helped me out:
"Solidworks kinda sucks, in the same way notes does. Their object's provide
a type lib, but don't repsond to requests for that typelib at runtime."
Anyway, now I need to get some useful examples together. What are some things you guys do that are a HUGE pain
in the ass? Or maybe something you think would be cool to do that requires a lot of scripting or repetetive stuff? At
some point I will rewrite my Custom Properties GUI but that won't happen this wwek... ;o)
Markus.
How about hiding update holders when SW starts? That sounds like a nice
demo-sized project.
"Nick E." <ni...@flyingpigs.com> wrote in message news:<b0-dnQ_iQbD...@giganews.com>...
>
> How about hiding update holders when SW starts? That sounds like a nice
> demo-sized project.
>
> --
> Dale Dunn
> Design Engineer
> www.jamestool.com
bob z. will second that one. bob z. has often awakened in the night with
'update holders' floating above his bed...
--
bob z.
p.s.
http://www.euronet.nl/users/frankvw/IhateMS.html
http://bobzeerocks.tripod.com/aboutbob/
go to http://www.cadsense.co.nz/swxwish.htm
search for linux and vote - even if you don't like linux
That sounds great, but now excuse my ignorance.....what is an Update
Holder?? I'm sure I use them everyday without knowing it, but can you
explain what it is?
(I guess I am not a hardcore SW guru...)
Thanks,
--
Markus
You probably turn them off every day. They appear at the end of an
assembly's Feature Manager Tree. They represent when any In-Context
relationships are updated. They are widely held to have very limited
usefulness. They are on by default for every session of SW.
> You probably turn them off every day. They appear at the end of an assembly's
> Feature Manager Tree. They represent when any In-Context relationships
> are updated. They are widely held to have very limited usefulness. They
> are on by default for every session of SW.
>
I assume this is not the same a fixing an In-Context part's external
references? I think I have seen them in my models...the "Update Sketch of
PartXXX" things hanging around at the bottom of the feature manager.
Hmmm...
--
Markus Wankus
Them's the ones.
just some PHP/MySQL/HTML stuff.
for now anyways.
regards,
nick e.
p.s. wow. #9. :)
Ricky Jordan wrote:
--
OK, sorry. But how do you go about turning them off? I cannot see any reference to something called an Update
Holder, and I have never turned one off. I recall locking External references on individual parts, but I am assuming this
is different from what you are referring to.
BTW, what version are you talking? I am still on 2001+.
--
Markus
They've been there since at least SW99, when I started. RMB on the assembly
name at the top of the FMT. "Hide Update holders" should be there. I did a
search in the API help and found that they go by a slightly different name
in the API (like other things). Anyhow, under swUserPreferenceToggle_e is
swIncontextFeatureHolderVisibility.
It's actually on my list of things I'd like to do with VB, I just need the
time to (figure out how) do it.
Ah, OK. No problem - done and done. However, I had a pretty cool idea the other day, which I am working on
implementing. I am going to post the Python stuff and put together a tutorial-type webpage as soon as I finish up. I
hope you will all be very impressed....
---
Markus.
P.S. Nice website by the way, Dale. Very clean. Tell whoever did it I like it a lot.
Thanks. Now I'll have to go look at it. I haven't actually checked it out
is a couple years....Oh that's interesting. Apparently, I'll have to find
out who's responsible for maintaining that thing.
Keep us (me) informed.