Quantcast
Channel: Ruby API - SketchUp Community
Viewing all 3018 articles
Browse latest View live

Components colission detection or checking if point is inside solid

$
0
0

@m07t0m wrote:

Is there any easy way to check if point is inside component, or if two components sharing the same space.
I was checking bounding box, but bounding box do not follow the object when it’s rotated. Any other ideas?

Posts: 3

Participants: 3

Read full topic


Trouble modifying Parametric plugin

$
0
0

@gnebster wrote:

parametric.rb (10.5 KB)

I’m using the “Parametric” plugin that was created by Trimble awhile back and am attempting to modify it to suit my needs. The plugin in short allows you to create “Parametric” objects that you can edit using a context menu option that prompts the user for values.

I am having a couple issues which I’ve been trying to solve without adding a ton of unneeded complexity.

I’m unsure how to allow for the ordering of parameters within the inputbox. I’m assuming I’d need to include the proper ordering in the inheriting classes somehow but haven’t been able to come up with a simple solution.

I have a few other issues with the prompt method. One being the inability to add drop down option lists to the inputbox. I know how you do it normally but not while fitting with the structure of the Parametric code. I’ve thought maybe I need to include this in the inheriting class along with the solution for ordering parameters and override its prompt method changing it slightly but am drawing a blank on how exactly to go about doing this.

Lastly, I’d like to be able to supply Parametric objects with some data that is hidden from the user when they attempt to edit it. The reason I want to do this instead of relying on constants is because in some cases I will be creating Parametric objects automatically with data supplied from a spreadsheet. In those cases the extra data would be supplied but I don’t want to bog the user down with a ton of input options that they don’t care about.

I don’t expect anyone to do all this for me but I would greatly appreciate any suggestions anyone has to offer.

Thank you

Posts: 2

Participants: 2

Read full topic

Programacion de Extensiones

$
0
0

@quemarcello wrote:

Señores, soy nuevo en el foro quisiera saber si hay alguien que podria orientarme en la programacion de extensiones , soy arquitecto y trabajo con sketchup, estoy muy interesado en aprender hacer el plugins, cualquier alcance me seria de mucha ayuda, por mi idioma es un poco dificil conseguir informacion, pero si hay un buen manual yo lo traduciria no hay problema.

LES AGRADEZCO

Posts: 1

Participants: 1

Read full topic

Exporting: Animation, Printers, & Time-out's

$
0
0

@AAcevedo wrote:

Hello again All - I’ve been trying to write a script that will automatically export still images, an mp4 animation, and send scenes to a printer. The still images were easy enough to figure out, but I’m not sure about the others:

  • As the still images export, Sketchup bogs down so I update the Status Text to show which image is currently being written. Two images in, the Windows loading cursor pops up, and the Status Text no longer updates. Any way to keep Sketchup from timing out?
  • Is it even possible to export scenes to an mp4 file? I haven’t had much luck on the API documentation… Does the Animation class have anything at all to do with it?
  • Should I go through the Win32 class to get access to my local printer? I’m actually using a PDF writer as a bootleg method for exporting all scenes to PDF’s, and combining them without using additional software (anyone got a better method that?)

Thanks in advance for any thoughts!

Posts: 1

Participants: 1

Read full topic

Uncheck icons for each new project

$
0
0

@dynamiqueagencement wrote:

Hello everyone.

As the title of the topic indicates, I’d like to uncheck icons for each new open SketchUp model.

I tried using “onNewModel” and “@@ icon.set_validation_proc {MF_UNCHECKED}”, but I did not succeed.

How would you do that?

Thank you

David

Posts: 2

Participants: 2

Read full topic

PickHelper by Layer

$
0
0

@medeek wrote:

Is there a way to limit the PickHelper to only select entities that are on a specific layer.

Posts: 1

Participants: 1

Read full topic

How to set and put an object to an layer with ruby script in sketchup

$
0
0

@rene.remmelzwaal wrote:

i have an question… how to select an object in sketchup with ruby script and how to put the
selected object to an specific layer

Posts: 3

Participants: 3

Read full topic

Deleted component instances in script

$
0
0

@jelcynek wrote:

Hello. I’ve got big problem with counting deleted elements in my ruby script. Here is below piece of code I use to count components definition and its instance on scene. is_snapping_point_component_definition is just function which checks if function fulfill condition for being treated as interesting component from my point of view.

So basically I’m searching for all component deifnition and its instances which are still valid and count them.

def self.set_snapping_points_visibility(value)
count = 0
count2 = 0
definitions = Sketchup.active_model.definitions.select { |d| is_snapping_point_component_definition?(d) }
definitions = definitions.uniq
puts 'Component count: ’ + definitions.length.to_s
definitions.each { |d| d.instances.each { |i| count2 += 1 if i.valid? } }
puts 'Entity count: ’ + count2.to_s
end

But very strange behaviour is there. If I add item to empty scene everything is fine. But after deleting instances from scene (even purging everything from scene and leaving blank), numbers are still the same as before deletion. First I told it was because I need to check deleted/valid flag and then I’ve added that check. But that didn’t help. However creating new document restore back numbers to 0.

Any ideas? I just think that I don’t understand how Sketchup is storing instances.

Posts: 3

Participants: 2

Read full topic


Projecting a texture to a curved surface

$
0
0

@JMZ wrote:

Hi all,

I’m very new to Sketchup and relatively new to programming in general so I’m sorry if there is an easy answer to this question. I understand how to project a texture onto a curved surface from a reference face in Sketchup to avoid texture stretching (manually in the Sketchup Field/non-ruby API), but I’m wondering if it is possible to project a texture with a ruby script.

I’ve learned how to apply a custom texture to whichever face I want with code from browsing the forums, but I can’t seem to find any way to project the texture using script. Is this possible with a Ruby script? I’ve read that the command for choosing the direction for projection from a face does not work properly.

This is my first post on here so I don’t know if I’ve described my situation well enough or if I’ve provided all the necessary information. I’m using Sketchup Make 2017.

Any advice will be helpful,
Thanks

Posts: 2

Participants: 2

Read full topic

[Example]An example to help you how to write SketchUp Ruby code with HtmlDialog

$
0
0

@Camlaman wrote:

I know how difficult it is to learn how to use the SketchUp Ruby HtmlDialog Class. Especially when the examples on the API documentation are so minimal. I hope this helps some beginner like myself.

The code snippet gets some user input from a web dialog and draws a box in SketchUp. I wrote this example myself so forgive me any programming mortal sins I’ve committed in it, I’m entirely to blame.

    	
        dialog = UI::HtmlDialog.new(
	{
	  :dialog_title => "Dialog Example",
	  :scrollable => true,
	  :resizable => true,
	  :width => 500,
	  :height => 300,
	  :left => 200,
	  :top => 200,
	  :min_width => 50,
	  :min_height => 50,
	  :max_width =>1000,
	  :max_height => 500,
	  :style => UI::HtmlDialog::STYLE_DIALOG
	})
	html = "
	<!DOCTYPE html>
	<html>
	<head>
	<title>FMS Test Dialog
	</title>
	</head>
	<h1>Draw a Box from a HtmlDialog</h1>
	<script>
	function sendDataToSketchUp() {
		var user_input1 = document.getElementById('id1');
		var user_input2 = document.getElementById('id2');
		var user_input3 = document.getElementById('id3');
		sketchup.getUserInput(user_input1.value, user_input2.value, user_input3.value)
	}
	</script>
	<body>
	<p>An example using SketchUp Ruby HtmlDialog</p>
	<form>
		length: <input id='id1' type='number' name='length' value=50 required><br>
		breadth: <input id='id2' type='number' name='breadth' value=75 required><br>
		depth: <input id='id3' type='number' name='depth' value=25 required>
	</form>
	<button onclick='sendDataToSketchUp()'>Draw Box</button>
	</body>
	</html>
	"
	dialog.set_html(html)
	dialog.show
	dialog.add_action_callback("getUserInput"){|action_context, user_input1, user_input2, user_input3|
		puts("JavaScript said user_input1 is #{user_input1}, user_input2 is #{user_input2} and user_input3 is #{user_input3}.")
		width = user_input1.to_f
		breadth = user_input2.to_f
		depth = user_input3.to_f
		model = Sketchup.active_model
		entities = model.active_entities
		pts = []
		pts[0] = [0, 0, 0]
		pts[1] = [width, 0, 0]
		pts[2] = [width, breadth, 0]
		pts[3] = [0, breadth, 0]
		# Add the face to the entities in the model
		face = entities.add_face(pts)
		face.pushpull depth
	}

Posts: 13

Participants: 4

Read full topic

DPI scaling and HTMLDialogs

$
0
0

@eneroth3 wrote:

Hi all

I’ve recently started using HtmlDialogs for my new extensions and was wondering if anyone knows this.

I usually develop on Windows 7 with no high DPI scaling. The pixel measurements I set for the dialog in Ruby and the pixel dimensions in my CSS maps 1:1 to screen pixels.

I have just tested my plugin on my friend’s computer in Win 8 with 125% scaling. My CSS dimensions still map 1:1 to screen pixels, but the dialog itself is sized up by factor 1,25 in each direction, making the layout somewhat wonky.

I was under the impression that both the dialog and its content should be scaled up by the same factor. Does anyone know if this is just a Win 8 oddity, or if it applies to Win 10 and Mac as well?

Posts: 17

Participants: 7

Read full topic

How Can I Copy a Projected Texture With Ruby Script

$
0
0

@JMZ wrote:

Hi all,

In Sketchup I can manually make a texture one face1 “projected” and use the eyedropper tool to to copy that texture onto another face2. The texture is then already “projected” on face2. I want to do this same thing, but with ruby script.

With ruby script I know how to apply a texture to face1 and use face1.set_texture_projection(face1.normal, true) to make the texture “projected”. But, I cannot find a way to copy that texture onto face2 and have it already be “projected.” Is there any way to do this with ruby script?

The context is that I want to take a face that is normal to a curve, apply a texture to it, make the texture projected, and then “eyedrop” that texture onto the curved face so that it does not get distorted.

Any feedback would be great, thanks.

Posts: 6

Participants: 4

Read full topic

Where is SketchUp2018 HtmlDialog preferences stored?

$
0
0

@eneroth3 wrote:

Up to SU2017 on Windows HtmlDialog and WebDialog preferences (positions) are stored in the registry. I regularly delete these values when working on my extensions to see how dialogs appear in their initial state when the user first starts the extension. However I can’t find these values in SU2018. I can’t find them in appdata either. Does anyone know where they have gone?

Posts: 8

Participants: 4

Read full topic

Vegetal attributes

$
0
0

@simjoubert wrote:

Good evening

I am a French landscaper.
I want to use the date parameter of sketchup shadows to display my plant components according to the season.
Mr Dan had helped me a lot last year to get the date parameter and create a “season” attribute corresponding to the day of the year (1 - 365).
he even added a context menu.

Today, after a while, I am resuming its development.

All my components will be structured with the same hierarchy:

*Component
*Group “persistent vegetation”
* Group “Annual Vegetation”
* Group “Flowering”
* Group “Fruiting”

The component will receive attributes:

  • season (thanks to Dan’s code)

https://forums.sketchup.com/t/set-attribut-date-shadow-dynamic-component/42371

  • annual vegetation date early

  • annual vegetation end date

  • flowering date early

  • flowering end date

  • fructification start date

  • Fruiting end date

  • Annual vegetation display

  • Flower display

  • Fruit display

  • season OnOFF
    The name of the component is variable but not the name of the subgroups.
    I wish to have the code to retrieve the name of the component select in variable to use it in a formula for the definition of a hidden attribute for each group

hidden attribute = component name! flower display

here is the code already

 # encoding: UTF-8
 # Module Définition attributs des végétaux
 # Auteur Simon Joubert
 
 ### Label Parametres Vegetaux
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_000", "PARAMETRES VEGETAUX"
    s.set_attribute "dynamic_attributes", "_vgtx_000_access","VIEW"
    s.set_attribute "dynamic_attributes","_vgtx_000_formlabel","***********" 
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
  ### Nom de la plante
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_001", "Nom de la plante"
	s.set_attribute "dynamic_attributes","_vgtx001_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_001_access","TEXTBOX"
    s.set_attribute "dynamic_attributes","_vgtx_001_formlabel","Nom" 
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
  ### Type de plante
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_002", "Arbre"
	s.set_attribute "dynamic_attributes","_vgtx002_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_002_access","LIST"
    s.set_attribute "dynamic_attributes","_vgtx_002_formlabel","Type de plante"
	s.set_attribute "dynamic_attributes","_vgtx_002_options", "Arbre=Arbre&Arbuste=Arbuste&Vivace=Vivace&Grimpante=Grimpante&Aquatique=Aquatique"
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
   ### Origine de la plante
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_003", "Existant"
	s.set_attribute "dynamic_attributes","_vgtx003_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_003_access","LIST"
    s.set_attribute "dynamic_attributes","_vgtx_003_formlabel","Origine"
	s.set_attribute "dynamic_attributes","_vgtx_003_options", "Existant=Existant&Fourniture=Fourniture"
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
 
  ### ************************************************* 

 ### Label Parametres Saison
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_020", "PARAMETRES SAISON"
    s.set_attribute "dynamic_attributes", "_vgtx_020_access","VIEW"
    s.set_attribute "dynamic_attributes","_vgtx_020_formlabel","***********" 
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
 ### Label Parametres Végétation annuelle
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_021", "DATE"
    s.set_attribute "dynamic_attributes", "_vgtx_021_access","VIEW"
    s.set_attribute "dynamic_attributes","_vgtx_021_formlabel","VEGETATION ANNUELLE" 
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
  ### Végétation annuelle début
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_022","14"
	s.set_attribute "dynamic_attributes","_vgtx022_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_022_access","LIST"
    s.set_attribute "dynamic_attributes","_vgtx_022_formlabel","Debut"
	s.set_attribute "dynamic_attributes","_vgtx_022_options","aucun=0&janvier=1&mi-janvier=15&fevrier=32&mi-fevrier=45&mars=60&mi-mars=74&avril=91&mi-avril=105&mai=121&mi-mai=135&juin=152&mi-juin=166&juillet=182&mi-juillet=196&aout=213&mi-aout=227&septembre=244&mi-septembre=258&octobre=274&mi-octobre=288&novembre=305&mi-novembre=319&decembre=335mi-decembre=349&fin decembre=365"
	$dc_observers.get_latest_class.redraw_with_undo(s)
  end
   ### Végétation annuelle fin
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_023","319"
	s.set_attribute "dynamic_attributes","_vgtx023_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_023_access","LIST"
    s.set_attribute "dynamic_attributes","_vgtx_023_formlabel","Debut"
	s.set_attribute "dynamic_attributes","_vgtx_023_options","aucun=0&janvier=1&mi-janvier=15&fevrier=32&mi-fevrier=45&mars=60&mi-mars=74&avril=91&mi-avril=105&mai=121&mi-mai=135&juin=152&mi-juin=166&juillet=182&mi-juillet=196&aout=213&mi-aout=227&septembre=244&mi-septembre=258&octobre=274&mi-octobre=288&novembre=305&mi-novembre=319&decembre=335mi-decembre=349&fin decembre=365"
	$dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
   ### Label Parametres Floraison
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_031", "DATE"
    s.set_attribute "dynamic_attributes", "_vgtx_031_access","VIEW"
    s.set_attribute "dynamic_attributes","_vgtx_031_formlabel","FLORAISON" 
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
  ### Floraison début
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_032","152"
	s.set_attribute "dynamic_attributes","_vgtx032_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_032_access","LIST"
    s.set_attribute "dynamic_attributes","_vgtx_032_formlabel","Debut"
	s.set_attribute "dynamic_attributes","_vgtx_032_options","aucun=0&janvier=1&mi-janvier=15&fevrier=32&mi-fevrier=45&mars=60&mi-mars=74&avril=91&mi-avril=105&mai=121&mi-mai=135&juin=152&mi-juin=166&juillet=182&mi-juillet=196&aout=213&mi-aout=227&septembre=244&mi-septembre=258&octobre=274&mi-octobre=288&novembre=305&mi-novembre=319&decembre=335mi-decembre=349&fin decembre=365"
	$dc_observers.get_latest_class.redraw_with_undo(s)
  end
   ### Floraison fin
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_033","196"
	s.set_attribute "dynamic_attributes","_vgtx033_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_033_access","LIST"
    s.set_attribute "dynamic_attributes","_vgtx_033_formlabel","Fin"
	s.set_attribute "dynamic_attributes","_vgtx_033_options","aucun=0&janvier=1&mi-janvier=15&fevrier=32&mi-fevrier=45&mars=60&mi-mars=74&avril=91&mi-avril=105&mai=121&mi-mai=135&juin=152&mi-juin=166&juillet=182&mi-juillet=196&aout=213&mi-aout=227&septembre=244&mi-septembre=258&octobre=274&mi-octobre=288&novembre=305&mi-novembre=319&decembre=335mi-decembre=349&fin decembre=365"
	$dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
  ### Label Parametres Fructification
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_041", "DATE"
    s.set_attribute "dynamic_attributes", "_vgtx_041_access","VIEW"
    s.set_attribute "dynamic_attributes","_vgtx_041_formlabel","FRUCTIFICATION" 
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
  ### Fructification début
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_042","182"
	s.set_attribute "dynamic_attributes","_vgtx042_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_042_access","LIST"
    s.set_attribute "dynamic_attributes","_vgtx_042_formlabel","Debut"
	s.set_attribute "dynamic_attributes","_vgtx_042_options","aucun=0&janvier=1&mi-janvier=15&fevrier=32&mi-fevrier=45&mars=60&mi-mars=74&avril=91&mi-avril=105&mai=121&mi-mai=135&juin=152&mi-juin=166&juillet=182&mi-juillet=196&aout=213&mi-aout=227&septembre=244&mi-septembre=258&octobre=274&mi-octobre=288&novembre=305&mi-novembre=319&decembre=335mi-decembre=349&fin decembre=365"
	$dc_observers.get_latest_class.redraw_with_undo(s)
  end
   ### Fructification fin
  mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_043","274"
	s.set_attribute "dynamic_attributes","_vgtx043_units", "STRING"
    s.set_attribute "dynamic_attributes", "_vgtx_043_access","LIST"
    s.set_attribute "dynamic_attributes","_vgtx_043_formlabel","Fin"
	s.set_attribute "dynamic_attributes","_vgtx_043_options","aucun=0&janvier=1&mi-janvier=15&fevrier=32&mi-fevrier=45&mars=60&mi-mars=74&avril=91&mi-avril=105&mai=121&mi-mai=135&juin=152&mi-juin=166&juillet=182&mi-juillet=196&aout=213&mi-aout=227&septembre=244&mi-septembre=258&octobre=274&mi-octobre=288&novembre=305&mi-novembre=319&decembre=335mi-decembre=349&fin decembre=365"
	$dc_observers.get_latest_class.redraw_with_undo(s)
  end
  
      ### Végétation annuelle ETAT
   mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_102", "FALSE"
	s.set_attribute "dynamic_attributes","_vgtx_102_units", "BOOLEAN"
    s.set_attribute "dynamic_attributes", "_vgtx_102_access","VIEW"
    s.set_attribute "dynamic_attributes","_vgtx_102_formlabel","Fleurs"
    s.set_attribute "dynamic_attributes","_vgtx_102_formula", "if(OR(vgtx_023,vgtx_022)=0,TRUE,if(vgtx_023>vgtx_022,if(season>=vgtx_022,if(season<=vgtx_023,FALSE,TRUE),TRUE),if(season>=vgtx_023,FALSE,if(season<=vgtx_022,FALSE,TRUE))))"
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
   ### Floraison ETAT
   mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_103", "FALSE"
	s.set_attribute "dynamic_attributes","_vgtx_103_units", "BOOLEAN"
    s.set_attribute "dynamic_attributes", "_vgtx_103_access","VIEW"
    s.set_attribute "dynamic_attributes","_vgtx_103_formlabel","Fleurs"
    s.set_attribute "dynamic_attributes","_vgtx_103_formula", "if(OR(vgtx_033,vgtx_032)=0,TRUE,if(vgtx_033>vgtx_032,if(season>=vgtx_032,if(season<=vgtx_033,FALSE,TRUE),TRUE),if(season>=vgtx_033,FALSE,if(season<=vgtx_032,FALSE,TRUE))))"
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end
   ### Fructification ETAT
   mod = Sketchup.active_model
  sel = mod.selection
  sel.grep(Sketchup::ComponentInstance).each do |s|
    s.set_attribute "dynamic_attributes","vgtx_104", "FALSE"
	s.set_attribute "dynamic_attributes","_vgtx_104_units", "BOOLEAN"
    s.set_attribute "dynamic_attributes", "_vgtx_104_access","VIEW"
    s.set_attribute "dynamic_attributes","_vgtx_104_formlabel","Fruits"
    s.set_attribute "dynamic_attributes","_vgtx_104_formula", "if(OR(vgtx_043,vgtx_042)=0,TRUE,if(vgtx_043>vgtx_042,if(season>=vgtx_042,if(season<=vgtx_043,FALSE,TRUE),TRUE),if(season>=vgtx_043,FALSE,if(season<=vgtx_042,FALSE,TRUE))))"
    $dc_observers.get_latest_class.redraw_with_undo(s)
  end

I understand it as it is but it can surely be simplified. it will surely add debugging but I start in ruby.

The final desire is to have a toolbar with 4 buttons.
1 Define the plants + season attribute
2 update the attributes after changing the date of the shadow parameters
3 redraw the plant components of the model.
4 force the display of all groups season = off
Thanks for your help

I like the idea of ​​going away, but the time I can devote to it is insufficient for my taste and my empty pockets. so thank you for your indulgence, I start.
Thank you for the time you will be able to accommodate me.

Simon

Posts: 1

Participants: 1

Read full topic

How to find the rotation of the entity?

$
0
0

@rajawat wrote:

I want to find the rotation of an entity around an axis.

I am using following piece of code

    e = Sketchup.active_model.entities[0]
    t = e.transformation
    a = t.to_a
    rotX = Math.acos(a[5]).radians

a) Initial State


Return the rotX as 180 degrees

b) Now rotate it anti-clockwise direction around red axis by 45


Return the rotX as 135 degrees

c) Now rotate it clockwise direction around red axis by 45


Return the rotX as 135 degress.

What am I doing wrong here ? Why rotation returned is same in both cases ?

Posts: 3

Participants: 3

Read full topic


Dc error when DefinitionsObserver added

$
0
0

@MarkoL wrote:

I keep getting this eror when I add DefinitionsObserver. Eror appears on a unode / redo event.

Error: #<TypeError: reference to deleted Entity>
c:/users/marko/appdata/roaming/sketchup/sketchup 2018/sketchup/plugins/su_dynamiccomponents/ruby/dcobservers.rbe:908:in get_attribute' c:/users/marko/appdata/roaming/sketchup/sketchup 2018/sketchup/plugins/su_dynamiccomponents/ruby/dcobservers.rbe:908:inonActivePathChanged’

Do I do something wrong or is it a bug? Here’s a simple script after which I get that error:

class MyDefinitionsObserver < Sketchup::DefinitionsObserver
  def onComponentAdded(definitions, definition)
    puts "onComponentAdded: #{definition.name}"
  end
end
@test = MyDefinitionsObserver.new
Sketchup.active_model.definitions.add_observer(@test)

EDIT:
Now I have noticed that the error also appears without a observer, when all entities in the component or group are deleted.
So it’s not up to me! :slight_smile:
Thanks anyway!

Posts: 2

Participants: 2

Read full topic

Rubymine debug error SketchUp Pro 2018

Setting up SketchUp debbuger for Rubymine on Windows

$
0
0

@Googlemo wrote:

I was following this guide https://github.com/SketchUp/sketchup-ruby-api-tutorials/wiki/RubyMine-Debugger-Setup

And for some reason it feels like my sketchup isn’t working(Im using sketchup pro2014). I copied SURubyDebugger.dll into C:\Program Files (x86)\SketchUp\SketchUp 2014\

And after this step:
cd C:\Program Files (x86)\SketchUp\SketchUp 2014
SketchUp.exe -rdebug “ide port=7001”

Program starts and looks like this:

My Rubymine settings for debugging look like this:

Here is external tool:

And here is debug-sketchup.rb:

At the end Rubymine can not connect to debugger(it gets an error after timeout, I tried changing it to 60s, didn’t help). Also when I start debbugin in Rubymine it starts new instance of the SketchUp program…

I feel like Im not doing something basic, but I have no idea what! Please help me :blush:

Posts: 1

Participants: 1

Read full topic

Using Dir.pwd with Cyrillic user-name etc

$
0
0

@TIG wrote:

I am having issues with a few Windows users who have non-ASCII user names.
This is affecting several scripts.
I can replicate it by creating temporary folders etc using such characters.
Particularly Cyrillic and Korean characters.

Oddly when I use Sketchup.temp_dir it can return a folder-path that looks at first sight to be wrong:
e.g. …/Антон/… >>> …/3EC2~1/…
However, when used in File.exist?(…) etc it is taken to be a valid path !
So that works despite it’s odd appearance…
I suspect that it’s the old MSDOS version of the file name ?

My main issue is when I try to use Dir processes.
I need to remember the current working directory - using pwd=Dir.pwd
Then use Dir.chdir(…) to change to a new temporary directory, when some file downloading and processing is done.
Then use Dir.chdir(pwd) to set things as they were.
It fails because the pwd reference substitutes characters as it’s made.
…/Антон/… >>> …/?????/…
And it’s always reported as being UTF-8 encoded in every case.

The first chdir is more than likely to work, because of the valid, but oddly referenced, folder-path to the user’s temp folder.
BUT the second chdir to reset things fails - because the pwd string is invalid - the specified folder …/?????/… can never exist, a ? is an invalid character in a file-path !
Clearly I can trap for that error, but then the user’s current working-directory is foobar !

So my question is, what other way could I establish a reference to a current directory for the reset code ?
Dir seems to be a dead-end because the returned string from pwd is already processed with the ?????.
Interestingly if I use Dir.entries… on the folder’s parent folder path it is listed as “?????”, BUT if I use Dir.glob… it gets listed properly using its Cyrillic name Антон !
So it is possible to see it, but not to get its currentness.

Using IO.read on a temporary text file into which I’ve previously written the current folder-path as a string, also returns the string with ?????, so that doesn’t work either !

Using a cmd shell in Windows to cd to its parent directory and dir a make list shows it correctly named, but of course its currentness is not accessible.

All ideas welcomed…

Posts: 9

Participants: 3

Read full topic

What formula can I use to calculte the info given by UVHelper?

$
0
0

@Neil_Burkholder wrote:

I’m trying to calculate the same information as what is given by the SketchUp::UVHelper class, in C# where I don’t have access to this neat class.

I would like to be able to input the normal vector of a given mesh (face) and then input any point3D and be able to receive output as a point2D. I’ve searched for several days and simply can’t come up with a formula that works.

Does anyone know what formula the UVHelper uses to calculate the UV positions? @thomthom? @DanRathbun?

Here are some more questions I have posted.

Posts: 2

Participants: 1

Read full topic

Viewing all 3018 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>