Sketchup_Importer
Sketchup_Importer copied to clipboard
Macos
A couple of minor changes to allow your fork to be built on macOS. I've not tested it extensively, but it builds, installs and imports ok using Blender 4.0.2, macOS Sonoma on an Apple M1 mbp.
Hi @tonfdd
Would you be able to provide a bit more context. At which step does it fail?
- build
- install
- import .skp file
Please could you provide any terminal / blender console output to help track down the issue.
Hi @tonfdd
Would you be able to provide a bit more context. At which step does it fail?
- build
- install
- import .skp file
Please could you provide any terminal / blender console output to help track down the issue.
Tks for support After replacing the init.py file, you may need to build. Could you provide more details about the specific steps you’re unsure of in the build process?
Hi^ The addon does not work on blender 4.0 with Sonoma 14.1.2.
After adding the addon to blender, I can’t check the box to enable it
Grey for me in Blender 4.02, MacOS 12.7.2 (Monterey).
Built as follows: Downloaded python 3.12, did pip3 install setuptools (got 69.1.0), pip3 install Cython. Copied the .framework files from SketchUp SDK to the install dir.
Had to remove /usr/local/include due to some old crud causing " error: unknown type name 'uint64_t' " After that, build script runs. Did the last two lines manually as instructed, replacing python version (312)
Copied the frameworks to sketchup_importer. Copied sketchup.cpython-312-darwin.so to sketchup_importer, renamed it to sketchup.so
Made a Zip of the sketchup_importer directory. Added that to add-ons in Blender Edit -> Preferencess. Extension appears, but is not selectable. Trying to select it causes error in Blender:
Traceback (most recent call last): File "/Applications/Blender.app/Contents/Resources/4.0/scripts/modules/addon_utils.py", line 364, in enable mod = importlib.import_module(module_name) File "/Applications/Blender.app/Contents/Resources/4.0/python/lib/python3.10/importlib/_init_.py", line 126, in import_module return _bootstrap._gcd_import(namef[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in __gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/Users/dare/Library/Application Support/Blender/4.0/scripts/addons/sketchup_importer/_init_.py", line 35, in <module> from . import sketchup ImportError: dlopen(/Users/dare/Library/Application Support/Blender/4.0/scripts/addons/sketchup_importer/sketchup.so, 0x0002): symbol not found in flat namespace (_Py_Version)
(edit: gah several mistakes in my report, hope I got most of them, that's what I get for doing this while sick)
Hi @darishante,
I think the issue comes from building the plugin with Python 3.12 when Blender 4.0.2 uses Python 3.10.
Here are the steps I took to build a working version with 3.10. Hopefully, it works for you too.
- Install Python 3.10
brew install [email protected]
- Copy SketchUpAPI.framework (I use the 2023 version of the SDK) to the repo folder.
- Working in the repo folder, remove some of the Windows build cruft inherited from the main branch.
rm ./sketchup_importer/sketchup.cp37-win_amd64.pyd ./sketchup_importer/sketchup.cp39-win_amd64.pyd ./sketchup_importer/sketchup.cp310-win_amd64.pyd ./sketchup_importer/sketchup.cp311-win_amd64.pyd ./sketchup_importer/SketchUpAPI.dll ./sketchup_importer/SketchUpCommonPreferences.dll ./sketchup_importer/bak.py
- Setup a clean python build environment. Note, I'm using the explicitly versioned instances of python and pip.
python3.10 -m venv env
source env/bin/activate
pip3.10 install Cython
- Build the plugin.
python3.10 setup.py build_ext --inplace
mv sketchup.cpython-310-darwin.so ./sketchup_importer/sketchup.so
install_name_tool -change "@rpath/SketchUpAPI.framework/Versions/A/SketchUpAPI" "@loader_path/SketchUpAPI.framework/Versions/A/SketchUpAPI" ./sketchup_importer/sketchup.so
install_name_tool -change "@rpath/SketchUpAPI.framework/Versions/Current/SketchUpAPI" "@loader_path/SketchUpAPI.framework/Versions/Current/SketchUpAPI" ./sketchup_importer/sketchup.so
- Package up the plug-in.
mv SketchUpAPI.framework ./sketchup_importer/SketchUpAPI.framework
zip -r sketchup_importer.zip sketchup_importer
Hi @tobiasjewson Followed these steps to rebuild plugin using python 3.11 which Blender 4.1 also is built on. I can successfully build and enabled the plugin in Blender 4.1. I could import a .skp file but it throws AttributeError: 'Object' object has no attribute 'layers'.
Any suggestions please?
Hi @balarayen,
Since the plugin builds and loads, I'm going to say that the issue is not with this specific branch but with the plugin more generally. Try to strip down the .skp file to the simplest possible version that still fails and submit an issue against the main repo.
Tobias
Another simpler .skp file imports well in Blender. Thanks for your response and suggestions @tobiasjewson !
Hi @darishante,
I think the issue comes from building the plugin with Python 3.12 when Blender 4.0.2 uses Python 3.10.
Here are the steps I took to build a working version with 3.10. Hopefully, it works for you too.
It did! I could add the extension and import simple and complicated models! Thank you so much!
@tobiasjewson @balarayen @darishante Please, can you upload here MacOS Blender 4.1 version? Really appriciated!
@balarayen +1 for the Mac version please.
@odil24 @KevJames Please see if this helps: Blender4p1_Addon_sketchup_Importer.zip
@balarayen Tried it with Blender 4.1 on an M2 MacBook running Sonoma and unfortunately it didn't work
Copy LayOutAPI.framework and SketchUpAPI.framework from SDK directory to pyslapi but there is no pyslapi so I assumed it meant slapi
... but maybe it just meant repo dir since this repo was forked from one named slapi
,
…I had to add -F ./slapi
to the flags:
diff --git a/setup.py b/setup.py
index c5eae9d..72f78fe 100644
--- a/setup.py
+++ b/setup.py
@@ -16,10 +16,10 @@ if platform.system() == 'Linux':
elif platform.system() == 'Darwin': # OS X
libraries = []
- extra_compile_args = ['-mmacosx-version-min=10.9', '-F.']
+ extra_compile_args = ['-mmacosx-version-min=10.9', '-F.', '-F./slapi']
extra_link_args = ['-mmacosx-version-min=10.9',
'-F',
- '.',
+ './slapi',
'-framework',
'SketchUpAPI']
well, when that didn't work, I tried to cut out the middle man and build using /Applications/Blender.app/Contents/Resources/4.1/python/bin/python3.11 directly
but it turns out this python (in the blender.org download which is also what brew installs):
A. doesn't include libpython (its statically linked into the bin?) or any of its headers (there is a Blender.app/Contents/Resources/4.1/python/include/python3.11/pyconfig.h
, which I imagine is insufficient, but also it ain't gonna find it ...)
B. has a pretty bad case of "hardcoded to the person who built its computer" (Prefix: /Users/brecht/dev/build_darwin/deps_arm64/Release/python
)
so that certainly can't help with anything
I'mma try building my own blender bin I guess ... but that seems pretty daunting when the git clone
has been running for 11 min to get to 96%
EDIT: for the record the 4.2 daily's python has the same properties, modulo that its /Users/raulito/…
instead of /Users/brecht/…
its a particularly in some ways silly and in some ways opportune time to be attempting this build given that the 4.2 release branch merged to main 5 hours ago blender/blender@840457c45c86b1d6b497dee96314b01d0672aeee
(its also very silly that they have a GitHub mirror of that repo but don't actually have mirrors of the 5 target specific lib, datafiles, or test submodules )
I probably should have (discovered and) gone for: https://download.blender.org/source/blender-with-libraries-4.1.0.tar.xz
maybe it'll slow down or cmake output has me fooled but its looking very possible that actual build time is slower than clone and submodules and lfs download time
annnnd building yourself still uses a pre-compiled python (https://projects.blender.org/blender/lib-macos_arm64/src/branch/main/python ) which in turn has bad hardcoded links to other libs (like openssl)
and they only hung an all or nothing make deps
on the blender makefile (though if I were better at CMake I might be able to figure out how to narrow scope)
there is logic in the build system to avoid this:
https://projects.blender.org/blender/blender/src/commit/983b0b61826794b1c372b4bc13e8754df379bc9b/build_files/build_environment/cmake/harvest.cmake
https://projects.blender.org/blender/blender/src/commit/983b0b61826794b1c372b4bc13e8754df379bc9b/build_files/build_environment/darwin/set_rpath.py
but something isn't working right
EDIT: There is also some logic perhaps specifically about sanitizing the python install but its guarded to Windows only (and works with .dlls): https://projects.blender.org/blender/blender/src/commit/983b0b61826794b1c372b4bc13e8754df379bc9b/build_files/build_environment/cmake/package_python.cmake
Well the "good" news is that after:
-
doing a clone and
make update
per https://developer.blender.org/docs/handbook/building_blender/mac/ -
starting and then canceling a
make deps
after it had finished downloading source tarballs (maybe just should have let it run) -
going into
../build_darwin/deps_arm64/
(from the blender repo), effectively doingrm -rf build/*/src/*
; doingmake external_ssl external_bzip2 external_lmza external_sqlite external_ffi external_zlib external_python external_python_site_packages
-
editing the Makefile to remove the
all
dependency onpreinstall
and editing down thecmake_install.cmake
to just the python parts[^1] and runningmake install
(this probs could have just beenrsync -a Release/python ../../blender/lib/macos_arm64/python
) -
doing
cd ../../blender/lib/macos_arm64/ && git diff --name-status python | grep '^D' | awk '{print $2}' | xargs git checkout HEAD --
to restore packages I'd deleted but not rebuilt (with anrm -rf lib/macos_arm64/python
before any of this; so ymmv) -
doing
cd ../../
(back to the blender repo) &&make
&&rm -rf /Application/Blender.app && mv ../build_darwin/bin/Blender.app /Applications/Blender.app
all of which is probably just to make there be resolvable-on-disk values in
/Applications/Blender.app/Contents/Resources/4.3/python/lib/python3.11/config-3.11-darwin/{Makefile,python-config.py}
(and might actually have been in practice mostly to resolve the silent presumably accidental inclusion of a dep from this python on homebrew
libb2
(v0.98.1) for computingblake2
ciphers)
-
Still also doing
cp -r lib/macos_arm64/python/include/* /Applications/Blender.app/Contents/Resources/4.3/python/include
-
following directions but doing
/Applications/Blender.app/Contents/Resources/4.3/python/bin/python3.11 setup.py build_ext --inplace
- after
cp ~/Downloads/SDK_Mac_2024-*/*.framework .
and - before doing
install_name_tool -change @rpath/SketchUpAPI.framework/Versions/A/SketchUpAPI \ @loader_path/SketchUpAPI.framework/Versions/Current/SketchUpAPI \ sketchup.cpython-*.so && \ mv sketchup.cpython-*.so sketchup_importer/sketchup.so && \ mv *.framework sketchup_importer
- after
-
installing manually as
mkdir -p ~/Library/Application\ Support/Blender/4.3/scripts/addons && \ cp -r sketchup_importer ~/Library/Application\ Support/Blender/4.3/scripts/addons/
-
Opening Blender.app and doing (Edit > Preferences; Add-ons tab) [v] -> "Refresh Local", and checking the box for "SketchUp Importer"
I was succesfully able to import an skp from 3D Warehouse into Blender 4.3 Alpha (blender/blender@983b0b618267)
[^1]: (20 of the 100-some blocks in which they irritatingly aren't actually using the concept of CMAKE_INSTALL_COMPONENT at all; also several in which they ostensibly are fixing rpaths of .so's in the site-packages dir)
did open a blender issue https://projects.blender.org/blender/blender/issues/123764
but the concern is probably pretty niche
Hello, I cannot import my file. Can anyone help me?
Unfortunately, I can’t enable the plugin in Blender 4.1.1 on macOS 14.5. Imports fine, with no errors. But the checkbox isn’t able to be toggled to the On state. Bummer.
I use pc on windows10
Le sam. 13 juill. 2024 à 16:05, Fuzen Co. @.***> a écrit :
Unfortunately, I can’t enable the plugin in Blender 4.1.1 on macOS 14.5. Imports fine, with no errors. But the checkbox isn’t able to be toggled to the On state. Bummer.
— Reply to this email directly, view it on GitHub https://github.com/RedHaloStudio/Sketchup_Importer/pull/2#issuecomment-2227090616, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJRP3EJ2XVIHWKPYHPIQIFTZMGB7DAVCNFSM6AAAAABCZCYUNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRXGA4TANRRGY . You are receiving this because you commented.Message ID: @.***>
I wonder why this hasn't been merged yet?
I dont have any knowledge in python or coding but can anyone give instructions as to how i can build it to get it working for blender 4.2 on macos ventura?