Last active
October 25, 2024 20:46
-
-
Save dgalli1/5d34b322b6e120ae383ef3a9c5f89c2b to your computer and use it in GitHub Desktop.
Create a github Repository For Freecad with string comparision
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASE_DIR="$HOME/git/cad" | |
# Check if a repository name was provided | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <repository-name>" | |
exit 1 | |
fi | |
REPO_NAME=$1 | |
FULL_PATH="$BASE_DIR/$REPO_NAME" | |
# Create a new private GitHub repository | |
if ! gh repo create "$REPO_NAME" --private; then | |
echo "Failed to create GitHub repository" | |
exit 1 | |
fi | |
# Clone the repository | |
if ! git clone "[email protected]:$(gh api user --jq '.login')/$REPO_NAME.git" "$FULL_PATH"; then | |
echo "Failed to clone repository" | |
exit 1 | |
fi | |
# Change to the repository directory | |
cd "$FULL_PATH" || exit 1 | |
# Add gitattributes for FreeCAD files | |
echo '*.FCStd diff=strings' >> .gitattributes | |
echo '*.FCStd merge=ours' >> .gitattributes | |
# add gitignore for freecad backup files | |
echo '*.FCStd1' >> .gitignore | |
echo '*.FCBak' >> .gitignore | |
# Add and commit .gitattributes | |
git add .gitattributes | |
git add .gitignore | |
git config diff.strings.textconv strings | |
git commit -m "Init Repository for Freecad" | |
git push | |
# Create new FreeCAD project | |
FreeCADCmd -c "import FreeCAD; doc = FreeCAD.newDocument('$REPO_NAME'); doc.saveAs('$FULL_PATH/$REPO_NAME.FCStd')" | |
# Open the project in FreeCAD GUI | |
freecad "$FULL_PATH/$REPO_NAME.FCStd" > /dev/null 2>&1 & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script requires github-cli with a logged-in user and a valid ssh key.
Additionally, you have to set the compression level in FreeCAD to zero.
You can change this setting under Edit -> Settings -> Document -> Compression level
Based on: FreeCAD/FreeCAD#9432 (comment)