Why different results:
Sketchup.version
7.0.10247
Sketchup.version_number
7000999
??
Why different results:
Sketchup.version
7.0.10247
Sketchup.version_number
7000999
??
After making a helper-DLL RubyCall.dll I get further progress:
@unknownuser said:
require 'Win32API'
true
newLISP = Win32API.new("C:\Program Files\Google\Google SketchUp 7\Plugins\newlisp.dll", "newlispEvalStr", ['P'], 'P')
#Win32API:0x8d26ef8
newLISP.Call("(import {C:\Program Files\Google\Google SketchUp 7\RubyCall.dll} {CreateRuby})")
CreateRuby <499C1B4>newLISP.Call("(import {C:\Program Files\Google\Google SketchUp 7\RubyCall.dll} {EvalRuby})")
EvalRuby <499C23C>newLISP.Call("(get-string(CreateRuby ""))")
"Ruby interpreter loaded!"newLISP.Call("(get-string(EvalRuby {name = Sketchup.app_name}))")
"Google SketchUp"newLISP.Call("(import {C:\Program Files\Google\Google SketchUp 7\RubyCall.dll} {GetRubyOutput})")
GetRubyOutput <499C338>newLISP.Call("(get-string(EvalRuby {puts "Hello World!";test = 2+2}))")
"4"newLISP.Call("(get-string(GetRubyOutput ""))")
"Hello World!\r\n"
So now I get back all kind (types) of return-values and the accumulated consol-output form ruby's puts commands.
Oops, I missed that info.
And the german site is also still on SU 6.
Only the Google Blog had mentioned that other languages for SU7 are ready.
But you can still not buy/download them here.
@unknownuser said:
..Sketchup also has a free viewer ..
But there is no viewer for SU 7.
So the free SU 7 standard is used.
Thanks for the info.
So the "User Friendly" label makes it easier.
Maybe could be used to change the GUI language also.
Is the "User Friendly" label settable from ruby?
I am a bit puzzled.
I read about the alphabetical sorting of the attributes in the book text.
But there are hardcopys of 'components options' dialogs in the book, which shows a circular stair and there are options not in the alpabetical order.
I then downloded the SKP and it show also the label which are not in alpabetical order.
Since I have not SU 7 Pro yet, I can not look into the DC config.
So is there a difference between attribut name and shown label?
@unknownuser said:
....if that helps.
Not really.
01_FrontColor
02_BackColor
Does not look nice. And in the DC-rules you have to use this workaround in the formulas.
And for a different language you start all again:
01_FrontFarbe
02_RückwandFarbe
By the way: Can a ruby detect in which language SU is running?
Regards,
Hans-Peter
Just got my book 'SU 7 for Dummies' and I read there that attribute always appear in alphabetical order.
I think this is a big mistake in the design.
There maybe attributs which need to be filled in a logical order.
I need a value first to porcess a possible second value etc.
The hint in the book about prefixing the attribute looks in the result unprofessional.
The attribute field-name should not affect the form of visuall interface.
Like in a DB it should be a logical field-name and how the label of the data-entry form is, should be configurable.
So a attribut should get a field with a settabel attribute 'displayed field name'.
And the component definition should get a stored order of attributes for each DC.
Now I would have to make each DC every time new for each GUI-language!
Or do I miss something?
Hans-Peter
Nice code snippet!
But why are there material names in different format:
<.....>
[.....]
.....
And is this the only possibility to see filepath?
In SU material editor I only see filename.
But when I get a SKP from other users there is a embedded material where the path does not exist on my PC.
Making slow progress with ruby calling after inspecting the exported functions from msvcrt-ruby18.dll:
require 'Win32API'
true
newLISP = Win32API.new("C;\\Program Files\\Google\\Google SketchUp 7\\Plugins\\newlisp.dll", "newlispEvalStr", ['P'], 'P')
#<Win32API;0x813bb48>
newLISP.Call("(import {C;\\Program Files\\Google\\Google SketchUp 7\\msvcrt-ruby18.dll} {rb_eval_string})")
rb_eval_string <1CF2F30>
newLISPret = newLISP.Call("(rb_eval_string {puts \"Ruby called from Lisp\"})")
Ruby called from Lisp
4
newLISP.Call("(rb_eval_string {VERSION})")
47157480
Not sure what the return-value 4 or 47157480 from rb_eval_string means.
What is the return-type of ruby's VERSION?
Still searching to get values from ruby-calls back to newLISP.
@unknownuser said:
do they have a Mac friendly version?
Lutz (creator of newLISP) wrote on the newLISP-forum:
@unknownuser said:
Should be possible, the newLISP library behaves like a normal C library on Mac OS X with cdecl calling conventions.
So can Ruby on the MAC import C librarys?
@unknownuser said:
But ultimately, you're right, if you find it useful for your work, knock yourself out.
That was my point here, I see it as an addition to ruby and not an replacement.
Of cource some kind of callback-possibilitys would be even better.
I have done this in enviroments like delphi and neobook.
So still room for improvments.
@unknownuser said:
If it has no bindings to the underlying SU objects, whats the point?
First it can be usefull for someone who wants to import lisp-base data into SU.
And when there would be any DLL which would export such command for accessing the SU objects newlISP could '(import ....)' this command.
Are there other extensions with bindings to SU?
newLISP runs on the MAC and on a lot other plattforms.
I am not sure about the DLL/SO-calling from ruby to modules on the MAC.
I posted a related question to the OSX section in the newLISP forum.
As a longtime supporter of the newLISP-project (http://www.newlisp.org/) I was interested in running the interpreter in SketchUp.
Looking at the various sample of the ruby-Win32API here in the forum and my previous experiences with embedding newLISP in other enviroments let me try it out.
So I copied Win32API.so and the newlisp.dll into the plugin folder.
Here is the console view:
require 'Win32API'
true
newLISP = Win32API.new("C;\\Program Files\\Google\\Google SketchUp 7\\Plugins\\newlisp.dll", "newlispEvalStr", ['P'], 'P')
#<Win32API;0x836c938>
newLISP.Call("(sys-info)")
(363 268435456 360 1 0 2048 6064 10003 70)
newLISP.Call("(setq a(+ 10 10))")
20
newLISP.Call("(setq b(+ a 10))")
30
You see that you can pass a lisp-string from ruby to newlisp and get back a result-string.
Variables preserve their state between calls.
Reading Lisp-Data gets a lot easier with access to an lisp-interpreter!! )
Note: newLISP is GPL so you may install it seperatly and load it from:
"C:\Program Files\newlisp\newlisp.dll"
For question on newLISP take a look to the exelent doc or visit the forum:
@unknownuser said:
At least if you have AutoLisp experience exporting the xdata in a usable format for Ruby would be relatively straightforward...
Thanks for your thoughts about extending such interface.
I had thought about this for myself, but I have to make steps one after another.
So first I want to get the structure in place again and then I can thought about adding/transporting more Info.
The AutoLisp experience is not the problem, since I am a nearly full-time autolisp-developer and I am really used to do anything with ExtendedEntityData.
We have logical propertys and geometric propertys stored in EED and even small chunks of Lisp-code stored there, which gets fired under certain events.
So I can imagine I could do similar things in the future with ruby.
@unknownuser said:
Sounds like your rewriting parts of my XrefManager for me ?
Nope, we have a block-structure of artikels with a master-slave relation ship build on EED-Data which gets lost during export/import. (As far as I know, or does Sketchup supports EED?)
And it would make sense to rebuild the structure on a group-base.
I found your nice ComponentReporter+.rb here and get the list of imported components.
Now I have to start with ruby (My main language ist still autolisp) and have to parse the component-names to lists and get some group building code to work with the components which belong to the new group (which then must be named with the same name as the first entry).
So still lots to learn!
Hans-Peter
Are the here metioned observers helpfull to get a OnImport event?
I would be intrerested to start a houskeeping script whenever I import one of our Autocad.DWG
(Making a layer purge/layer switching and building groups from hierarchy-info contained in blocknames)
Hello,
It would be a usefull addition to the autocad import settings dialog, if it would get a option to set up a optional import feature, to have the ACAD-color of a 3DFACE-primitive on both sides of the imported face.
In Autocad much user does not care about face-orientation and Autocad show the choosen color on both sides of the face. So the user does not even recognize his failure.
After importing them in SketchUp they wonder that they see the default-color gray (backface) on the visible side.
Such an option would sketchup make more tolerant against bad modelling in autocad.
Regards
Hans-Peter
Thanks again. I missed this options-button.
Thanks for the tip.
Works as suggested.
All guides has gone.
Other question: My Autocad data was made in metric/mm and now I get a wrong length.
Must I convert my Autocad to Inches before importing.