Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with VB Macro code 2

Status
Not open for further replies.

Tobin1

Petroleum
Nov 9, 2007
176
Howdy!

I’m just beginning to learn a bit about the SW API. In the past I used AutoLISP in AutoCAD for productivity enhancements. But I didn’t get into VB at the time. I’ve been using SW daily for a little over a year now. I downloaded a few nice SW Macro’s and recorded a couple of my own.

I’ve found a Macro (AddViewLabel) that is very close to something that would help me label views the way I need to more efficiently. AddViewLabel is a collaborative effort by Matthew Lorono and Regg. I contacted Mr. Lorono to discuss an addition to the code. He’s agreeable with trying to add something to the code.

I need to change the view label’s because, as I’m sure you are all aware, SW uses only one text size for both lines of the view label it produces. I need the last line (the scale) to be a smaller text size than the other lines.

I’d like to change the AddViewLabel's code so it will do the following:
1) Use the SW “Section View Text” text size setting for the first two lines the Macro creates (Firster and Seconder).
Currently the Macro uses the SW “Note” text size setting for all text size:
[get note annotation object]
[Set swAnnotation = swNote.GetAnnotation]
2) Use the SW “Note” text size setting for the third line the Macro creates (showme).
The Macro is currently set up to use this text size for all text.

As I said I’m a beginner at this. I can look thru the code and figure out some of what is going on but not enough to figure out how to add the above function.

Can anybody help me with this?


 
Replies continue below

Recommended for you

Tobin,
Just had to ask. You did a great job sir!

Colin

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2007 SP 5.0
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
I'm just a little verklempt. Talk amongst yourselves. I'll give you a topic. Pink Floyd, was neither Pink nor Floyd. Discuss!--“Coffee Talk” Mike Myers SNL
 
fcsuper

Yes it's "freeware/public domain/distribute freely", I like the Open Source idea. Kind of hard to do anything else with .swb files :) .

Tobin Sparks
 
Not really appropriate to take it further here. I will contact you via your website contact.

[bat]Honesty may be the best policy, but insanity is a better defense.[bat]
-SolidWorks API VB programming help
 
Tobin,

I've been playing with your macro. Some issues:

1. Remove unnecessary Reference libraries. One some systems, having certain unused libraries loaded will cause the macro not to function.

2. There appears to be an issue with the selection manager. I have issues with it recognizing the selected views more times than note (triggering error handling).

3. Should be a method within the form to change the font size and maybe even the type.

4. The form needs a little clean up. The error handling messages can have the name of the problem placed in the title of the windows, so you can clean those up too.

And, of course, the scale doesn't auto-update when the scale of the view changes, but you and I discussed that before. :)

And maybe add more detail about each of the default settings within the code and the help.

The form looks like a good first step and general concept.

When it does work, it works well. I like that you hide the actual label. I also like that it seems any actions taken by the macro can be undone with the standard SW Undo function.





Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
 
I would like to see SW incorporate Tobin's labeling into the general software code as an option when creating views. This will include the items mention in this thread about linking i.e view letters and scaling modifications.

These tiny enhancements really make a big difference to us guys and gals.

Colin

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2007 SP 5.0
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
I'm just a little verklempt. Talk amongst yourselves. I'll give you a topic. Pink Floyd, was neither Pink nor Floyd. Discuss!--“Coffee Talk” Mike Myers SNL
 
fcsuper

Thanks for your comments.
I obviously don't really know what I'm doing. :) Just a fairly good hack. But I'm learning. I recently discovered how to - make the error handling messages have the name of the problem placed in the title of the windows. I'll implement things as I learn. Your comment "Remove unnecessary Reference libraries" I'm not sure how to do that. I was thinking I had removed everything that was not neccessary for the Macro to run. I'll look into it more. Don't have a clue about how to address the selection manager issue. I was thinking of trying to make a way for the user to input a different font height. I'll have to think about it. I just wanted to start with something as simple as I could.

Thanks again - I appreciate your input.





Tobin
Tobin.Sparks@nov.com
 
macduff

WOW - Thanks for your remarks. I gald this is working for you. This is just the beginning and I'll let you in on the coming enhancements to this learning project :) .

Thanks

Tobin
Tobin.Sparks@nov.com
 
macduff,

I'll one up you. Even better would be if they allowed the user to adjust these factors in the first place. The fact that the section/detail labels are essentially locked out to the user is amazingly annoying.

Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
 
Matt,
That's what I kinda meant by my comment. My bad on my part. Yeah, it's really annoying. Another thing is really annoying is you can't add text to item balloons. I put numerous ER for this and SW never responded. I'm old school as far as drafting, I guess. I was taught a certain way to detail out drawings for aerospace, and SW locks you out of functionality as you mentioned.

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2007 SP 5.0
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
I'm just a little verklempt. Talk amongst yourselves. I'll give you a topic. Pink Floyd, was neither Pink nor Floyd. Discuss!--“Coffee Talk” Mike Myers SNL
 
macduff

Sorry it took so long to get to this -
Your statement "Another thing is really annoying is you can't add text to item balloons."
Could you elaborate on what you mean or send a screen shot showing what this might look like?
If it's what I'm thinking I'd like to try something :) .

Thanks

Tobin
Tobin.Sparks@nov.com
 
"Another thing is really annoying is you can't add text to item balloons."[/quote0

Have you tried the "Group" command? You can group a note and balloon together so that they stay together when moved.
 
TheTick,
Yeah...I know about grouping, but it's a pain to do an extra step. Plus if ya edit or delete items, you have to ungroup and regroup.

Tobin1,
Let me see if I call dig up the stuff i sent to SW on this.

I'll be back in a bit.

Colin

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2007 SP 5.0
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
I'm just a little verklempt. Talk amongst yourselves. I'll give you a topic. Pink Floyd, was neither Pink nor Floyd. Discuss!--“Coffee Talk” Mike Myers SNL
 
See attachment for the item balloon example I'm going after. Adding this would be a simple code change for SW. Let me know your thoughts. I think it's pretty slick, but I'll let you respond.


Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2007 SP 5.0
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
I'm just a little verklempt. Talk amongst yourselves. I'll give you a topic. Pink Floyd, was neither Pink nor Floyd. Discuss!--“Coffee Talk” Mike Myers SNL
 
 http://files.engineering.com/getfile.aspx?folder=46ebb3a9-fbde-4dba-ad58-846636d5296a&file=Item_Balloon_with_Text_Option.jpg
macduff

That's pretty much what I imagined you were talking about. Years ago in AutoCAD I made myself a balloon block (I actually still have it) that had attributes that could be used the way you are describing. The block didn't have the top and bottom positions for the text though. I regularly used the right and left positions. Do you find you use the top and bottom positions?
I have an idea but this might take me awhile. I'll let you know what I come up with.

Thanks

Tobin
Tobin.Sparks@nov.com
 
Cool, and thank you.

I use all the positions. The one that's irritating the most is not being able to put the text before the balloon because of the leader. Actually it would be cool if for one, SW to add the option we're talking about, and two....SW to add this to the auto ballooning and have it add the qty's i.e. 2X 6X 8X....when the option is selected.

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2007 SP 5.0
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
I'm just a little verklempt. Talk amongst yourselves. I'll give you a topic. Pink Floyd, was neither Pink nor Floyd. Discuss!--“Coffee Talk” Mike Myers SNL
 
macduff

I agree with you that this should be included in SW. It's almost like we're working with unfinished software. Of course there will always be room for improvement and I don't expect it to be even close to perfect, but this kind of thing just leaves ya wondering what they were thinking :) .
I'm pretty sure whatever I come up with will not be able to put text between the leader and balloon, but, I'll look into it. That just means the user will have to choose a text position that won't interfere with the leader.

Thanks for giving me a little something new to work on :) .



Tobin
Tobin.Sparks@nov.com
 
I like the way you think there, Tobin.

Keep me posted if you have something for me to test.

Best,

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2007 SP 5.0
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
I'm just a little verklempt. Talk amongst yourselves. I'll give you a topic. Pink Floyd, was neither Pink nor Floyd. Discuss!--“Coffee Talk” Mike Myers SNL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor