How to name a surface

Hi everyone! I’m using the extension DeLuminae and i want to name different surfaces (same area) to have these names in the report after a D-Light calculation. Does anyone has the answer?
Thanks

You can’t give a surface a name in SketchUp.

The process to prepare a model for the extension is outlined here: https://deluminaelab.com/dl-light-manual/en/howto_prepare_model.html

hey Dave! thanks for the answer!

In the report, we have an “ID surface”. Can we know in the modele wich ID correspond to wich surface?

Thx
image

Terminology and technical points may be crucial to the answer. I’m wondering if the question may be largely from the word “surface” as used in the French version of the report.

In your mind, what in SketchUp does “surface” mean? I suspect it is the equivalent of what in the English version is called a Face. A Face has a unique object number id as its key in the SketchUp geometry database, but it has no supported property for “name”. Note that in the example you provided, the “ID surface” and “Nom de la surface” are always the same numeric value.

Well i think i’m talking about “face” like you’re saying. I calculate this faces as “control point” in an shading study to compare the existing situation with the projected situation. So all the faces have the same area (1m2) to have precise resultate. But know i can’t distinguish the faces and can’t interpret the data. Do you have a clue how to manage it?

It depends what the spreadsheet ID & Nom refer to…
A face has various methods.
To get all of those containing ID/id select one face and use this in the Ruby Console…
f = Sketchup.active_model.selection[0]
then you should have a reference to face… use…
f.methods.grep(/[Ii][Dd]/)
You’ll get some unconnected methods like hidden !
The entityID is a short number = e.g. 1678 - this will vary by session
The persistent_id is a different short number - e.g. 1234 - this persists across sessions
The __id__ and object_id are the same very long number and are probably not relevant ?
So which of the first two types ?

Use this to find the relevant face… this is assuming it’s using persistent_id - otherwise replace that text with entityID.
First you need to select all of the likely faces - so it speeds up the searching…
Then copy+paste this into the Ruby Console and fill in the inputbox with an integer code…

r = inputbox(["Name: "],[0],"")
if r
  id=r[0]
else
  id=nil
end
m = Sketchup.active_model
s = m.selection
f = s.grep(Sketchup::Face).find{|f|f.persistent_id==id}
if f
  s.clear
  s.add(f)
else
  puts "No matching face selected."
end
puts

The model’s selection will now include just that specific face…
Or report failure.
Edit the input prompts, message box as desired e.g. into french…

Repeat the searching, re-selecting the likely faces first…

Hey Tig! thanks a lot for your response.
I tried what you proposed but i’m not used to use these kind of codes… so don’t understand all the process and i’m not sure what i am looking for at the end.
I think that persistent_id is more relevant like you said.
When i do a research with the first method, it gives me this: #Sketchup::Face:0x000002a64872d968
But it doesn’t correspond to an ID in the D-Light report…
The following methods doesn’t seem to give something… i’m a bit lost sorry…

Check this extension:
https://extensions.sketchup.com/extension/28691b5f-d472-4d26-a4d6-0a7c0b8068e0/kg-dev-select-by-id

Thanks Mike! It seems nice and easy but unfortunately i don’t find the IDs in the D-Light reports :confused:

So I suspect that your D-Light tool adds an attribute to the face which it then uses in the report…
So we have to find what that attribute dictionary is called and then what the face’s name key is etc…

So try this code…
Select one face you know has an ID/name.
In the Ruby Console…
f = Sketchup.active_model.selection[0]
Now get its attribute dictionaries
ads = f.attribute_dictionaries
then id there are any…
ads.each{|d| puts d.name }
If there’s an entry with a name that might look like D-Light or its author…
[In what follows let’s assume it’s named ‘DLight’]
ad=ads["DLight"]
then
ad.each_pair{|k,v| puts "#{k} = #{v}" }
The list should show the keys and the value…
From the ‘value’ you know for the ‘name’ you will now know the ‘key’.
Let’s assume it’s called ‘id’…
We can get its value thus…
id = ad['id']

So to insert that back into the earlier code block…
It uses the ‘assumptions’ listed earlier, tweak those to suit… i.e. ‘attribute_dictionaries’ name and its ‘key’

r = inputbox(["Name: "],[0],"")
if r
  id=r[0]
else
  id=nil
end
m = Sketchup.active_model
s = m.selection
f = s.grep(Sketchup::Face).find{|f|
  ad = f.attribute_dictionaries["DLight"]
  next unless ad
  ad["id"] == id
}
if f
  s.clear
  s.add(f)
else
  puts "No matching face selected."
end
puts

hello Tig! thanks for your research!
So i’m trying (i’m really bad with codes) what you say and it’s working (!!!) to find the id. I’ve got this as response:

ad=ads[“DL_faceData”]
#Sketchup::AttributeDictionary:0x00000210f5edd250
ad.each_pair{|k,v| puts “#{k} = #{v}” }
area = 1.0
id = 9
orig_mat_time = 1588865223
original_material =
original_material_position =
se = {“id”:9,“num_of_sensors”:1,“report”:“POINTS+DE+CONTROLE_f_9_SE_clear_sky_report.txt”,“sensor_file”:“POINTS+DE+CONTROLE_f_9_sensors.pts”,“sensor_file_json”:“POINTS+DE+CONTROLE_f_9_sensors.json”,“steps”:[“POINTS+DE+CONTROLE_f_9_shading.txt”,“POINTS+DE+CONTROLE_f_9_sensors_long.txt”],“surface_name”:“POINTS+DE+CONTROLE_f_9”,“survey”:“POINTS+DE+CONTROLE_f_9_sunexposure.txt”,“survey_zip”:“POINTS+DE+CONTROLE_f_9_sunexposure.zip”,“texture”:“POINTS+DE+CONTROLE_f_9.png”,“version”:10485768,“bound_rect_3d”:[[119.273499,-176.778179,137.834138],[119.273499,-175.778179,137.834138],[118.273499,-175.778179,137.834138],[118.273499,-176.778179,137.834138]],“size_m”:[1.0,1.0],“current_results”:“D:/R&D Ombrage/BELLIARD TEST/sunexposure_output/current/reports/POINTS+DE+CONTROLE_f_9_SE_clear_sky_report.txt”}
se_pts = [{“v”:9.647,“a”:1.0}]
sunexposure_material = _dl_fc_se_9
sunexposure_material_position = [[4695.807047244095, -6959.770826771653, 5426.540866141732], Point3d(1, 1, 0), [4695.807047244095, -6920.400748031496, 5426.540866141732], Point3d(1, 0, 0)]

So I have my id which is 9 in this case! But then i’m lost in the process :grimacing:
In id = ad['id'], I have to replace [‘id’] by [‘9’]? if i do that, I have this:
id = ad[‘9’]
Error: #<NoMethodError: undefined method `’ for nil:NilClass>

:in `' SketchUp:1:in `eval'

Thanks again it’s a big step!!

A face has the attribute-dictionary “DL_faceData” - a ‘string’ - you successfully get a reference to that ‘ad’.
In turn that has a ‘key’ named ‘id’ - you are getting that.
In the example your gave that key has a value of 9 - it’s a number aka an integer 9 - NOT a string “9” - so it’s id = ad['id']
You compare that to the ‘test’ value, if it’s a match we use select that face…

Note that in Ruby " and ’ are pretty much interchangeable to denote a string…

Below I recast the example code I gave using the up to date info…
Select ALL of the likely faces…
Then copy+paste the code below into the Ruby Console + enter…

r = inputbox(["Surface ID: "],[0],"")
if r
  id = r[0]
else
  id = nil
end
m = Sketchup.active_model
s = m.selection
f = s.grep(Sketchup::Face).find{|f|
  ads =  f.attribute_dictionaries
  next unless ads
  ad = ads["DL_faceData"]
  next unless ad
  ad["id"] == id
}
if f
  s.clear
  s.add(f)
  puts "\n\n\nFini.\n\n\n"
else
  puts "\n\n\nAucune surface correspondante sélectionnée.\n\n\n"
end
puts

As a test - enter 9 into the inputbox and press OK… and see if a face gets selected and that it matches what you expected…

Note I also swapped the strings into ‘french’ etc… and added some more error traps…

1 Like

YEAAAAY! it’s working very well! thanks a lot for your work and time!!
However it’s a pity that we can’t just click on the face and get his ID…
But thanks, it takes time to verify all my faces but i can use my data!!

1 Like

You can make the code into a simple tool to do that…
It’s more complex but uses the now working methods you have…

Here’s an RBZ.
It adds two new items to the Extensions menu.
“DL ID en clique surface” & “DL ID en surface ID”
The first reports the DL ID [if any] of a clicked face.
The second takes a DL ID input in a dialog and selects the matching face in the model [if any].

Install the RBZ using the Extension Manager > red-button…

DL_ID_v1.0.rbz (1.6 KB)

OMG!! I’m really impressed!! THANKS A LOT TIG! it’s exactly what I was looking for :ok_hand: :woman_cartwheeling: :champagne:

1 Like

Hi,

I am from De Luminae who publishes DL-Light.

That may of course be quite late but the answer could be used by others.

DL-Light has an internal ID system and each face can have a name. The ID is used to name faces by default.

When you have run a calculation, a report opens and in it you can see the name of the faces (surfaces in French). If you click on a surface in your model it will highlight the right line in the report and conversely if you click on a line in the report it will highlight the face in the model.

That was designed to help users find the faces.

Now if you double-click on the name of the face in the report you can modify it and put the name you want (bedroom first floor, etc…).

When you export as csv file (as you showed) in your screenshot you will have the ID (the DL-Light one) and the name if the surface.

If you can questions do not hesitate to contact us at support@deluminaelab.com

Hope this helps
JeanDo