you mean from Custom Properties?
It certainly looks that way. He's using custom properties to fill the block.
Here is a little info on the custom property manager that you need to create in VBA to be able to Get and Set custom properties. This should work without using configurations as well, so you can just grab the most important lines from that example.
Question to Gabriel: What's your experience with VBA macros in Solidworks?
Thank you for reply.
I am new with vba macros.
I've written a blog post on how to get started with SolidWorks macros. Start with that and create your own macro to do a few simple things, like creating an extrude feature or change the view orientation.
The code for adding and reading custom properties will then be pretty simple to implement. You can also have custom properties added to every part by default. I believe you can use the Custom Property Tab Builder like shown in this video by Innova Systems.
It is very important for me that the vba macro to work in sheet drawing.
I work with lot of configurations for a single part file.
so exactly what "block", I mean how you fill out your block,. you want to get parameters and write to custom properties?
I don't understand exactly what you're asking. Can you please be more specific about what values you are trying to move where?
You mention that you want to copy an attribute value but you don't state which one.
You mention that you want to copy a value to the Summary Information but the image you show has the Custom tab selected, not the Summary tab.
Also, attributes, as far as I can tell, can only be imported from AutoCAD. The SolidWorks Help indicates that they can be manually created but the process isn't clear on how to do this so I don't know how to create a block with attributes. Please either explain how this is done or provide a model that contains attributes in the block.
Please read this for future reference: How to ask a good question in the API forum
I'm still not sure what you want from this macro
I have a sheet metal part with multiple configurations. Each configuration have a unique number (NUMBER) that is written in Configuration specific(picture 1). When i make the drawing, I insert a block (picture 2) in the drawing witch is linkt to the part and can read that value(picture 3). I need to read from the block the value NRDESEN witch is $PRPSHEET:"Number" ( picture 3) and write it to the Summary Information in Custom tab of the drawing (picture 4). After I write that value to the Summary Information in Custom tab I need to export the drawing as a DWG or DXF file with than NUMBER (ex: R-0089487.DXF or .DWG) to the current location of the part in a folder caled "DXF".
Ok, I got you now
So you want to read the custom properties from a part and write to its drawing custom properties
Am I correct?
With this vba i manage to read the block.
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim longwarnings As Long
Dim swNote As Note
Dim partNo As String
Dim swSelMgr As SldWorks.SelectionMgr
Dim sketchTitleBlock As SketchBlockInstance
Dim vNote As Variant
Dim testString As String
Dim blockDef As SketchBlockDefinition
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set swSelMgr = Part.SelectionManager
boolstatus = Part.Extension.SelectByID2("TITLE BLOCK-2", "SUBSKETCHINST", 0, 0, 0, False, 0, Nothing, 0)
Set sketchTitleBlock = swSelMgr.GetSelectedObject5(1)
Set blockDef = sketchTitleBlock.Definition
vNote = blockDef.GetNotes
If Not IsEmpty(vNote) Then
testString = "Notes:" + Chr(13)
For i = 0 To UBound(vNote)
Set swNote = vNote(i)
testString = testString + "Tag: " + swNote.TagName + " Note: " + swNote.GetText + Chr(13)
If swNote.TagName = "AutoAttr0" Then partNo = swNote.GetText
longstatus = swApp.SendMsgToUser2(testString, swMbWarning, swMbOk)
longstatus = swApp.SendMsgToUser2(partNo, swMbWarning, swMbOk)
How can i write the value from NRDESEN (in this case is R-0089487-16) to the Summary Information Custom tab of the drawing?