Giter Club home page Giter Club logo

codestack's Introduction

CodeStack

🔗 https://www.codestack.net

CodeStack is a free online resource for learning programming and automating an engineering software, such as SOLIDWORKS.

There are hundreds of code examples and useful macros available for download.

Currently, CodeStack consists of following sections:

  • SOLIDWORKS Tools - a collection of useful automation macros to improve your productivity while using SOLIDWORKS
  • SOLIDWORKS API - a collection of example and tutorials of SOLIDWORKS API and macro development
  • SOLIDWORKS PDM Professional API - a collection of examples and tutorials of automating SOLIDWORKS PDM Professional using API
  • SOLIDWORKS Document Manager API - a collection of example and tutorials of accessing metadata of SOLIDWORKS files via Document Manager API
  • SOLIDWORKS eDrawings API - a collection of example and tutorials of automating of SOLIDWORKS eDrawings
  • Visual Basic - tutorial of Visual Basic (VBA) - popular language for writing macros in CAD systems and office applications

CodeStack welcomes contributors! If you found an error, typo, wish to extend the article, or add a new article we will appreciate your contribution. Please follow this blog post for contributing guidelines.

codestack's People

Contributors

andrmollo avatar artem1t avatar benoitbotton avatar eddyalleman avatar jaredmt avatar oldfcuk avatar snake-60 avatar stefan-sterk avatar xarial-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codestack's Issues

Macro request: Variant of 'Excel macro to manage custom properties'

Hi CodeStack,

See below for forum question:
https://forum.solidworks.com/message/1088036?commentID=1088036&et=watches.email.thread#comment-1088036

I am suggesting that CodeStack creates a variant of your existing macro to also include Cut-List item properties in an Excel command. This functionality would, in my opinion, work well with the existing macro (link below).

If the user is able to implement cut-list items in Excel similar to your existing macro, I'd imagine that they can use their user-form to populate excel with a list of SW Drawing files to read, get external references (SW Part filepaths), then use the excel functions to read their cut-list properties.
https://www.codestack.net/solidworks-document-manager-api/document/get-external-references/
https://www.codestack.net/solidworks-document-manager-api/document/data-storage/custom-properties/excel-functions/

Solidworks Macro - Replace Drafting Standard

I am looking for a macro that will replace the Drafting Standard in all parts, assemblies, and drawings per the "Document properties" starting with the Main assembly (opened) and all its references to getting updated.

Добрый день

Добрый день ищу макрос для SW. Что бы он вытягивал габаритные размеры, массу детали, материал, сортамент из модели в отчет Execel. Буду очень благодарен.

A way to name next component number in assemby

Hi everyone!
First of all I wanted to thank you for the work you are doing, very useful for the community that wants to improve themselves with solidworks.
In this regard, I wanted to ask you if there is a way with "VBA" to solve my following problem:
When I create a new assembly, and insert new virtual components (parts) inside it, it would be very helpful if there was a macro that automatically assigns a progressive numbering to their name. It would be perfect if this macro could be applied instantly as the new part (virtual component) is inserted.
Do you think it is possible? Thank you in advance for your kindness!

Need macro

Hi i work with solidworks and i hope this macro it's helps me for my work better

Macro to force reset feature name to its default name in solidworks

Hello I am requesting a macro kind of like one you guys already made. Except this will forcibly reset the feature name to what it was when the feature in solidworks was created. For example an existing part that has had "Boss-Extrusion1" changed to "100207141 Used In whatever extrusion". I would like this macro to strip what the use inputted and change it back to the default name.

Create STEP from file explorer

#Hello everyone,
First of all thank you for your precious work and for the development of SolidWorks add.

As is already existing for open in "quick view" mode an assembly or a drawing :
https://www.codestack.net/solidworks-api/getting-started/scripts/vbscript/open-quick-view/

I would like to know if it is possible to do the same with the save as step file command ?
The step will have the same name of the sldprt or sldasm, and save in the same directory.

I tried to modify the existing vbScript without result...
Thank you in advance for your support.

Adrien

Solidworks Macro for Balloons in drawing

Hello,

I've been searching the internet everywhere for a macro that will allow me to check for missing balloons and possibly add them to a drawing in solidworks.

I deal with assemblies with 500+ parts at times so its a very painful process at the moment.

thanks
John

solidworks macro- modify revision table

Hello, I was hoping I could get help for creation of a macro. I have a bunch of drawings (each drawing has at least one to 4 pages) and I need to update the revision table on each of them without deleting the actual revision table. For example, I have a revision table with one or more rows. I need to delete the rows, add a new row and change the name of the revision to A00. Please help!

Solidworks - Change Sketch Text Font size via VBA

Is there a way to change the font size of sketch text in a Solidworks part model using vba code.
I was hoping to just select the sketch in the tree containing the sketch text then run the code
to change the font size and font name. I need to do this for over 1000 models to meet my company's new
font parameters. Can anyone help?

SolidWorks Api

I'm looking for SolidWorks code to select all radii in the current sketch that is less than a specified dimension.

Thank You

Auto create the points

There are many holes in part A, and part B also need to create holes align the center of holes with part A.
I think the "CylinderParams" property may resolve this problem. I try it with macro in part, it is worked, but not in assembly.
Do you have any ideas?

Macro Request: Export all underlying drawings from Assembly to PDF

We're looking to digitizing our printed SolidWorks drawings to PDF's.
For this we need a Macro, which to my knowledge does not exist yet.

I've seen multiple PDF export macro's but none of which would fit our needs.

We have many different drawings in underlying parts and assembly's in a main assembly, which we would like to export all at the same time.
But since this different for each project we would also need to be able to select specified sheets and a folder.
I put an example in the attachment, which I made with Excel and Paint.
I tried to optimize the layout as best I could, but I'm open to suggestions.

I hope someone can help me with this, thank you in advance!

Example

Macro Request: Excel File Part Number and Description Manager

Per your comment on reddit, I am submitting a macro request. The purpose of this macro is to keep an up to date excel file of all part numbers and their descriptions. The idea is to run this macro either on the initial save or as a save as after a concept part is worth of a dedicated part number. Let's start with the initial save idea:

  1. User clicks macro button to run macro
  2. Macro opens hard coded excel file (excel file has two columns already titled Part Number and Description with a few entries)
  3. Macro identifies the last part number in the first column (eg 123456)
  4. Macro saves part to default location (or asks user for location) with file name as the next part number increment - 123457
  5. Macro enters 123457 in the first column of the next row (under 123456).
  6. User is prompted for a description and user enters the text (e.g. Left Gusset)
  7. Macro enters this descriptions in the second column next to the part number 123457.
  8. Macro enters description into part description of Solidworks part. (same description that shows up in the BOM table).

Optional: Description Update

  1. User clicks macro button to run macro
  2. Macro opens excel file
  3. Macro sees that the filename already has an entry.
  4. Popup asks user if they would like a new part number or if they want to update description
  5. user selects update description
  6. User enters new description into text window and selects OK
  7. Macro overrides the description next to the part number (wherever it was - not in a new row)

SOLIDWORKS- CREATE DXFS OF ALL SHEETMETAL PARTS IN OPENED ASSY

I was hoping i could get some help with a macro creation. I need a macro that will create all dxfs of sheetmetal parts in an open assembly. The dxf needs to have the following entities (geometry, hidden edges, library features, forming tools) . I have found other macros online that does a similar task but not exactly what i need. Hope you guys can help!

Enhancement request for existing macro "Export flat patterns from SOLIDWORKS part or assembly components"

Firstly, the macro as posted works well for me. Thanks!

For Inventor I've pieced together iLogic snippets that do what your SW macro is doing as well as additional functions. All together these save me a lot of time at work, using Inventor. And so, I'm inquiring to see if you'd have interest to add similar functionality to your existing SW macro.

The new macro suggested could work like this:

  1. From a top level assembly, recursively cycle through all components (including both parts and assemblies) and populate a custom property within each with:
    a) its total number of occurrences within the top level assembly
    b) a reference identifying the top level assembly that the macro runs from
  2. Verify, or create new flat patterns. Then flatten parts.
  3. Profile plate parts cut from DXF's are often machined afterwards. For Inventor, just before the DXF is exported I unsuppress all features having names containing "extra", as in extra stock. Conversely, I suppress all features having names containing "machine".
  4. Export the DXF with a filename that includes custom property data in the form: "-<mark, description or item> .dxf"
  5. Reverse the flat and suppression states altered in steps 2. and 3.

If you find it helpful, I can share my Inventor iLogic code that is presently performing steps 1 to 5, but be fair warned, I'm no programmer.

Solidworks Macro

I am looking for Solidworks Macro for "Exclude from Bill of Material"

Macro for sheet metal

Can any one help for making macro on making auto dxf ? (solidworks)
dxf should be save like below folder sequence and at the end we found dxf file.
DXF --> MS --> 2 MM --> part1.dxf

MultiBody Drawing

Hello,

This is my first request. I First want to point out that I'm relative new to writing macros. Nevertheless I am very excited to write my own macros and I am learning a lot from the macros on CodeStack.com

I am facing the following problem:

I use a lot of weldment modeling for designing machine elements. In order to have unique part numbers I rename the CutListItems according to the designated partnumber and a suffix of b1, b2 etc. Off coarse this step is done with a macro ;)

For the drawings I want one or two sheets of the whole multibody part for all the welding dimensions and annotations and add a sheet for every body (CutListItem) in the multibody part. It would be very nice and save a lot of time if I could run a macro that automatically puts all the individual bodies on a separate sheet and renames the sheets according to the CutListItemName of that body.

I hope you can help me writing this macro. All the attempts and Google searches I did so far where useless. See the attached picture to see what kind of parts I am working with and how I number all of my parts.

Kind Regards,

Nick
The Netherlands

wldmnt drawing

MACRO: CHECK & MODIFY POS Nr on a drawwing

Register macro demand
for SolidWorks 2019 SP3 / WIN10 64 bit
Target:
a.) check if all POS listed in a SW BOM are also present as POS on the drawing.
b.) if all missing pos. are present on the drawing
insert with the circle border and size 3
c.) if Pos Nr are present on the drawing,
change them all to circle border and size 3,
(selection of alternatives Formatting in advance
to be influenced beforehand.
d.) Highlight all item numbers on the drawing when clicking on the item and offer the possibility to move the item number outside the view; alternatively, adjust the alignment automatically for all items (move all item numbers outside the part outline if necessary).

Solidworks revision table macro

Hello,

I was hoping i could get help with a macro that deletes the current revision table and then adds a (pre specified) new revision table; Then adds a new row on the revision table. I would like the fields in the new row to be editable and controlled within the macro.

I would like to be able to have the macro make the changes to all the drawing files within a pre selected folder.

Capture

Custom Save As New macro for each Configuration in file. Save all as SLDLFP files

Here is my first attempt (just started learning today, so pleas forgive me).

Dim swModelDocExt As ModelDocExtension
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim DIR As String

Dim Name As String
Dim Version As Integer
Dim Options As Integer
Dim ExportData As Object
Dim Errors As Long
Dim Warnings As Long

Dim NAMES() As String
Dim Confg As SldWorks.Configuration

Dim EXT As String
Dim path As String
Dim fileName As String
Dim sizeCount As Integer

Dim value As Boolean

Sub main()

EXT = ".SLDLFP"
Set swApp = Application.SldWorks
swApp.Visible = True
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
Version = 0
sizeCount = 0
value = False
Warnings = 0
Errors = 0
Set ExportData = swApp.GetExportFileData(1)
DIR = swApp.GetCurrentWorkingDirectory

Dim temp As String
Options = 0

path = swModel.GetPathName
sizeCount = swApp.GetConfigurationCount(path)
ReDim NAMES(sizeCount)

NAMES = swModel.GetConfigurationNames
Set Confg = swModel.GetConfigurationByName(NAMES(0))
For i = 0 To sizeCount

temp = NAMES(i)

swModel.ShowConfiguration2 (NAMES(i))
Set Confg = swModel.GetConfigurationByName(NAMES(i))
fileName = Confg.Name
value = swModelDocExt.SaveAs("a:\" & fileName & EXT, Version, Options, ExportData, Errors, Warnings)
Next

End Sub`

AS MACRO: CHECK & MODIFY BOM POS ON A DRAWING SOLIDWORK 2019 SP3

Alois Metzger
Danke
Register macro demand
for SolidWorks 2019 SP3 / WIN10 64 bit
Target:
a.) check if all POS listed in a SW BOM are also present as POS on the drawing.
b.) if all missing pos. are present on the drawing
insert with the circle border and size 3
c.) if Pos Nr are present on the drawing,
change them all to circle border and size 3 if necesarry
(selection of alternatives Formatting in advance
to be influenced beforehand.
d.) Highlight all item numbers on the drawing when clicking on the item and offer the possibility to move the item number outside the view; alternatively, adjust the alignment automatically for all items (move all item numbers outside the part outline if necessary).
Thanks
Alois Metzger

Creat flat pattern view with annotation

Get the BOM of assembly, and create each Sheetmetal part flat pattern drawing in one slddraw file, and get the material, thickness, and quality value of the parts as annotation, list below the view. The part view that with same material and thickness will list in the same row.

Macro to save bodies and create assembly with all the configurations of original multi-body part.

I have needed this feature over and over for a while now, will pay for this macro. Say I have a multibody part that is a chest-o- drawers. I have made "small", "med" and "large" configurations in this multi-body part. I want this macro to create a single assembly of the chest-o-drawers with configurations of "small", "med", and "large" as well (Solidworks does not pass the configurations through the parts or assembly with the "save bodies" command). I would also like this new macro to strip special characters in the body name as well when saving to parts. To be clear, each part would contain each configuration and the assembly would contain each configuration selecting the configuration of each part.

Macro request

Can you create a macro for a part with multiple faces, each with a different color, that meshes the faces and records the vertices and color, so that the output would be the vertices and the color that each vertex “lies” on?

Save Cutlist Items as new parts

I work with a lot of weldments and have to save may of my cutlist items to new parts in order to create individual prints for the part because of special hole locations, bends, things of that nature.
I would like a Macro that would take any selected cutlist item, or multiply items, and automatically create a new part and save them under the same file location and part-cutlist name. It would be nice if it could create a new folder labeled "part name"-cutlist parts and save them into this folder.
This would save me a great deal of time when working with larger weldments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.