×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SOLIDWORKS VISUAL BASIC

SOLIDWORKS VISUAL BASIC

SOLIDWORKS VISUAL BASIC

(OP)
I am using Solidworks and have created a macro that populates text in a drawing sheet. It puts information in the custom properties that gets read by the text on the drawing sheet.

Is there a way to input text from your drawing sheet or custom properties into the text boxes or pulldown lists in the visual basic macro.

With no real programming experience I am struggling on this one, could anyone help. On another issue is there any code to center text on a drawing sheet

RE: SOLIDWORKS VISUAL BASIC

If I understand you correctly, you are filling the custom properties via FILE - PROPERTIES - CUSTOM in your part or assembly.

Then linking a note in your drawing to these custom properties.

And your question is how do I enter the the info/text from the drawing?



Remember...
       "If you don't use your head,
                       your going to have to use your feet."

RE: SOLIDWORKS VISUAL BASIC

And by centering text, do you mean centered within the note or the note centered within a drawing view or the note cetered on the drawing sheet?



Remember...
       "If you don't use your head,
                       your going to have to use your feet."

RE: SOLIDWORKS VISUAL BASIC

(OP)
You are correct on both counts,

I want the macro to read the text on my drawing sheet so that you dont have to keep typing it out again if you have made a simple spelling mistake.

the text I want to be centered in the note, but I will also need to move the text so that is in a central position in the title block

RE: SOLIDWORKS VISUAL BASIC

I need a little more info....

"macro to read the text" ???
don't quite understand what you're trying to achieve

You may be past this but ...
Here's how I handle these things.

1) Title block material is stored with the parts/assemblies because once the drawing templates are set-up with their associated references, they are filled in automatically.

ie. In the model file, if you add a custom prop called "Revision", the drawing template will always fill a note block with the following text "PRPSHEET:{Revision}" automatically when the first view is inserted.  Changing the custom prop data in the part/assy automatically updates the drawing when changed.

These note blocks shold be added to the sheet format via a right click on the drawing template - select EDIT SHEET FORMAT.  Then add as many note blocks as you wish - then right click again and select EDIT SHEET and save as a new template.

2)Revision block material is kept in the drawing properties area. They are accessed via a "PRP:{Revision}" format

There are SW API calls for both.
If you can post your code, it can be modified to suit your needs.

I don't know if your macro is to create these notes because they are different for each drawing or if you follow my method the macro can create the same properties for every part/assy/drawing and modify them as neded.



Remember...
       "If you don't use your head,
                       your going to have to use your feet."

RE: SOLIDWORKS VISUAL BASIC

(OP)
Let me try again,

I know how to create the custom property using visual basic and I know how to get it to populate the drawing. What I want to know is can you reverse this process, can you get your custom property to show up in your text boxes when you run your macro, so that you do not have to type all the information again, and again, and again, catch my drift.

RE: SOLIDWORKS VISUAL BASIC

Dim sConfig As String
Dim retval As Boolean

    sConfig = ""    'not config specific in this case
    
        'set all custom defaults
        Part.AddCustomInfo3 sConfig, "TITLETOP", swCustomInfoText, " "
            
    Load frmCustom
    
        'fill user interface data
        frmCustom.txtTT = Part.CustomInfo2(sConfig, "TITLETOP")

Then you will need:

        'update interface data
        retval = Part.DeleteCustomInfo2(sConfig, "TITLEBOT")
        retval = Part.AddCustomInfo3(sConfig, "TITLEBOT", swCustomInfoText, frmCustom.txtTB)



Remember...
       "If you don't use your head,
                       your going to have to use your feet."

RE: SOLIDWORKS VISUAL BASIC

Forgot to add...  modified for your use
      frmCustom, txtTB, TITLETOP, TITLBOT are all from my macro/SW addin

btw... Do you know there is a SolidWorks forum here on Eng-Tips?



Remember...
       "If you don't use your head,
                       your going to have to use your feet."

RE: SOLIDWORKS VISUAL BASIC

TheTick at the SolidWorks forum is good at this.

RE: SOLIDWORKS VISUAL BASIC

(OP)
meintsi

Thanks for your help, looking at your code helped. What I did was modify it to suit my needs, as shown below.

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

UserForm1.TextBox16.Text = Part.CustomInfo("REVISION")
UserForm1.TextBox15.Text = Part.CustomInfo("TASK")
UserForm1.TextBox9.Text = Part.CustomInfo("DESCRIPTION 1")
UserForm1.TextBox24.Text = Part.CustomInfo("DESCRIPTION 2")
UserForm1.TextBox25.Text = Part.CustomInfo("DESCRIPTION 3")
UserForm1.TextBox26.Text = Part.CustomInfo("DESCRIPTION 4")
End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close