working meanwhile...
thanks for the help.
But that part of the code:
if @woche.to_i >= start.to_i && @woche.to_i < ende.to_i #@woche variable of the class
e.material = mats["im_bau"]
e.back_material = mats["im_bau"] #why doesn't it work?
end
if @woche.to_i >= ende.to_i
e.material =mats["fertig"]
e.back_material =mats["fertig"] #why doesn't it work?
end
if @woche.to_i < start.to_i
e.material = mats["noch_nicht_angefangen"]
e.back_material = mats["noch_nicht_angefangen"] #why doesn't it work?
end
should have been working, shouldn't it?
I don't understand why the materials were assigned to the front, but not to the back of the face.
any idea?
Hallo!
I am going to set the material of a face in the following method. To avoid problems with the oriatation of the face's normal I want to set its back_material, too.
I tried it with the following code:
def status_anzeigen #funktioniert, nur das mit dem alpha wert im material inplanung noch nicht so
mod = Sketchup.active_model
ents = mod.entities
sel = mod.selection
mats = mod.materials
bau_mat = mats.add "im_bau" if not bau_mat = mats["im_bau"]
bau_mat.color = [255,127,38]
fertig_mat = mats.add "fertig" if not fertig_mat =mats["fertig"]
fertig_mat.color = [211,211,211]
inplanung = mats.add"noch_nicht_angefangen" if not inplanung = mats["noch_nicht_angefangen"]
inplanung.color = [176,196,222]
inplanung.alpha = 0.3
ents.each{|e|
if e.typename == "Face"
start = e.get_attribute "ablauf", "baubeginn" #attributes that were assigned to the faces before
ende = e.get_attribute "ablauf", "bauende" #attributes that were assigned to the faces before
if (e.material) #checking wehther the faces current material belongs to the ones created at the top of the method, if not, save the name of the current material as an attribut
invalid_materials = ["im_bau", "fertig", "noch_nicht_angefangen"]
unless invalid_materials.include?( e.material.name )
mat_vorher = e.material.name
e.set_attribute("ablauf", "material", mat_vorher)
end
end
if @woche.to_i >= start.to_i && @woche.to_i < ende.to_i #@woche variable of the class
e.material = mats["im_bau"]
e.back_material = mats["im_bau"] #why doesn't it work?
end
if @woche.to_i >= ende.to_i
e.material =mats["fertig"]
e.back_material =mats["fertig"] #why doesn't it work?
end
if @woche.to_i < start.to_i
e.material = mats["noch_nicht_angefangen"]
e.back_material = mats["noch_nicht_angefangen"] #why doesn't it work?
end
end
}
end
Only the "front" of the face was changed to the new material. Does anybody know what mistake I made?
Thanks for your time.
Tim
Hallo!
How is it possible to hide and unhide an entity?
Thanks for your time.
I study civil engineering and the script is some kind of homework. I'll talk to my tutor in two days. After that I'll know wether I'm allowed to give you the code.
Thanks so far.
Tim
Step by step what I want to do:
it is working so far. in the 3. step every entity on that layer seems to be erased. but if i invoke the scribt once more as mentioned in step 4, sketchup tells me:
"your recent operation has caused visible geometry to merge with existing geometry on a hidden layer"
although the is nothing to see.
do know now what i am trying to receive?
is there maybe an array that stores the entity although it got erased or something like that?
thank you guys for your time.
The geometry isn't disconected. I wrote a scribt that should display some information, that is saved as an attribute of the faces, in a diagramm an text on a different layer ("balkenlayer"). Then it should be possible to go on working on the model and to invoke the scribt that shows the information on "balkenlayer" again. So far the diagramm and the text is displayed on the layer and the geometry of it seems to be erased. But when I invoke the scribt one more time, Sketchup still tells me, that:
"your recent operation has caused visible geometry to merge with existing geometry on a hidden layer"
Although I meanwhile use the following code:
layer = layer_array["Balkenlayer"]
return nil if not layer
mod.entities.to_a.each{|e| next if not e.valid?; e.erase! if e.layer==layer}
I don't understand why.Though there is no geometry to see if only the "Balkenlayer" is visible.
Any idea?
But isn't that exactly the code I already used?
Hallo!
I wrote a scribt that creates some entity objects on a layer called "Balkenlayer". Now I try to write a scribt that deletes every entity object on "Balkenlayer" to be able to execute the first scribt I wrote more then only one time without having the entity objects created by the first invoking of the scribt on the layer.
As adviced I used
mod = Sketchup.active_model
mod.active_entities.to_a.each{|e| next if not e.valid?; e.erase! if e.layer==layer_array["Balkenlayer"] }
to delete the objects on Balkenlayer. But every time I invoke the first scribt that created the objects on "Balkenlayer" after the should have been deleted, Sketchup opens a window that tells me:
"your recent operation has caused visible geometry to merge with existing geometry on a hidden layer"
In the next step nothing happens.
Do you know what I have to change?
Thanks for your time.
Tim
Hallo!
I tried to delete a layer named "Balkenlayer" with the following code:
mod = Sketchup.active_model
layer_array = mod.layers
layer_array.each{|l|
if l.name == "Balkenlayer"
l.erase!
puts "Balkenlayer deleted"
end
}
Why isn't it working?
Thanks for your time.
Tim
Hallo!
Is it possible to deactivate or delete an observer after the observer has been invoken? Ideally in the observer itself.
Thanks for your time.
hmmm... ok. in this case i don't understand why the lines behaved like that. not that important.
ok, thanks to you once again.
the edges were on the same layer (tested it with test=e.layer; puts test)
could it be that lines only can be deleted, if they don't border a face?
i executed the script to delete the entities twice, in the first step only the faces were deleted. in the second step the lines were erased.
works with the faces, but all the lines aren't erased. any idea why?
first of all, thank you guys.
ok, the ...BulkChange observer responds.
is it possible to delete instead of the entities in the selection every entity on a certain layer?
Hallo!
I tried to write a script that displays in the ruby window the name of the layer the entity is arranged at everytime it gets selected. After that the entity should be erased. I used the folling code an it didn't work...
class Selbserver < Sketchup;;SelectionObserver
def onSelectionAdded(sel)
sel.each{|e|
layer=e.layer.name
puts layer
e.erase!
}
end
sel=Sketchup.active_model.selection
sel.add_observer Selbserver.new
#to load it
#load "C;/Users/tim/Desktop/observertest.rb"
end
i have no idea, why nothing happens when i load the script an select an entity after that.
thanks for your time.
i know meanwhile how to...
thanks a lot.
soungs good. and how to delete the note?
hi everybody!
is it possible to create a text in the corner of an image that is rendered with view.write_image at which the resolution of the rendered image differs from the width and height of the current view.
for example:
current view = 1600*1200
an image rendered with view.write_image 800, 800
(to save information of the current model on the image)
thanks for your time.
tim