OH, sorry I didn't see there was an attachment - sorry !
Posts made by ksor
-
RE: Push Pull direction?
-
RE: Push Pull direction?
OK - nice with your comments and alternative if's and I'll study that closely BUT
What about my WHILE-problem ?
Do you mean that IF I DO like you said then this problem will disappear or .. ? -
RE: Push Pull direction?
OK - some restructering but here is a code that WILL run correctly as it is now (WITH the out-commented lines 49, 56 and 68 !)
IF you "activates" the WHILE loop again (remove =begin, =end and the end to the WHILE in the lines 49, 56 and 68)
it reports an error missing an "end" in the end ??????????????????????=)(?/??=)(#?=)(?=#(¤/(#)=#&¤&
The meaning of the WHILE loop is to secure that some MINIMUM input values are obtained.HOW CAN ACTIVATING THE WHILE LOOP CAUSE THIS ERROR missing an "end" in the end when it was no problem before - what is wrong here ?
(For now never mind the modul and class lines)
Here is the code:
#module KSOR # class polley # store bogstaver evt. med _ er en CONST MINDIAP = 40.mm MINDIAA = 10.mm MINKRVD = 20.mm MINKRVB = 15.mm # First check for PC or MAC platform = (Object;;RUBY_PLATFORM =~ /mswin/i) ? ;windows ; ((Object;;RUBY_PLATFORM =~ /darwin/i) ? ;mac ; ;other) if platform.to_s=="windows" then # pull in the standard API hooks. require 'sketchup.rb' # Get handles to our model and the Entities collection it contains. model = Sketchup.active_model $entities = model.entities # Show the Ruby Console at startup so we can # see any programming errors we may make. Sketchup.send_action "showRubyPanel;" # Add a menu item to launch our plugin. UI.menu("PlugIns").add_item("Kileremskive") { # Call our new method. draw_pulley } else UI.messagebox("Denne facilitet er KUN til Windows !", MB_OK) end # end main program ----------------------------------------------------------------------------- def draw_pulley # labels for input fields prompts = [$exStrings.GetString("Skivediameter (mm) ;"), $exStrings.GetString("Akseldiameter (mm) ;"), $exStrings.GetString("Kravediameter (mm) ;"), $exStrings.GetString("Kravebredde (mm) ;")] # default MINIMUM values $diaP = MINDIAP $diaA = MINDIAA $krvD = MINKRVD $krvB = MINKRVB =begin while ($diaP < MINDIAP) || ($diaA < MINDIAA) || ($krvD < MINKRVD) || ($krvB < MINKRVB) # test for minimum values in ALL - change the one less than minimum if ($diaP < MINDIAP) then $diaP = MINDIAP if ($diaA < MINDIAA) then $diaA = MINDIAA if ($krvD < MINKRVD) then $krvD = MINKRVD if ($krvB < MINKRVB) then $krvB = MINKRVB =end values = [$diaP, $diaA, $krvD, $krvB] # Now display the input dialog results = inputbox prompts, values, $exStrings.GetString("Specifikationer") # Returner if no inputs return if not results $diaP, $diaA, $krvD, $krvB = results if ($diaP < MINDIAP) || ($diaA < MINDIAA) || ($krvD < MINKRVD) || ($krvB<MINKRVB) then UI.messagebox("Mindsteværdi er genindsat - de(n) SKAL overholdes !", MB_OK) end # end draw_beltProfile set_beltProfileOnWheel pull_pulley pull_krave end def draw_beltProfile pt1 = [0,4.22.mm,0] pt2 = [13.8.mm,0,0] pt3 = [13.8.mm,12.7.mm,0] pt4 = [0,8.48.mm,0] # Call methods on the Entities collection to draw stuff. $fullProfile= $entities.add_face pt1, pt2, pt3, pt4 $beltProfile = $entities.add_group $fullProfile.all_connected end def set_beltProfileOnWheel # Her laves en profil, som svarer til en kilerem # # Skive laves $periferi = $entities.add_circle [0,0,0], [0,0,1],$diaP.to_f/2,48 # transformation af helpLine på $beltProfile til Origo tr = Geom;;Transformation.translation [-11.55.mm,-0.69.mm,0] $beltProfile.transform! tr # og videre til cirkelperiferien tr = Geom;;Transformation.translation [$diaP.to_f/2,0,0] $beltProfile.transform! tr # rotate beltProfile 90° tr = Geom;;Transformation.rotation [13.8.mm,0,0], [1,0,0], 90.degrees $entities.transform_entities tr, $beltProfile # gruppen exploderes for at lave FollowMe og findes så ikke mere $beltProfile.explode $fullProfile.followme $periferi end def pull_pulley # Nu skal siderne på skiven laves 2 mm på hver side opSidePeriferi = $entities.add_circle [0,0,12.mm], [0,0,1], $diaP.to_f/2 + 2.25.mm, 48 opSideFlade = $entities.add_face opSidePeriferi opSideFlade.pushpull 2.mm nedSidePeriferi = $entities.add_circle [0,0,-0.7.mm], [0,0,-1], $diaP.to_f/2 + 2.25.mm, 48 nedSideFlade = $entities.add_face nedSidePeriferi nedSideFlade.pushpull 2.mm cleanUp end def cleanUp # En cylinderflade fjernes, så der åbnes ind til remprofilen end def pull_krave # En krave til nippel skruer laves efter angivne dimensioner # og der skal laves hul til akslen med den givne diameter end # end #class #end # module
-
Push Pull direction?
I try to do this while ..end loop:
<span class="syntaxdefault"> while </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$diaP </span><span class="syntaxkeyword"><</span><span class="syntaxdefault"> MINDIAP</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$diaA </span><span class="syntaxkeyword"><</span><span class="syntaxdefault"> MINDIAA</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$krv </span><span class="syntaxkeyword"><</span><span class="syntaxdefault"> MINKRVD</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$krvB</span><span class="syntaxkeyword"><</span><span class="syntaxdefault">MINKRVB</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># Now display the input dialog<br /></span><span class="syntaxdefault"> results </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> inputbox prompts</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> values</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $exStrings</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">GetString</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Specifikationer"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># Returner if no inputs<br /></span><span class="syntaxdefault"> return if not results <br /> if </span><span class="syntaxkeyword">((</span><span class="syntaxdefault">$diaP </span><span class="syntaxkeyword"><</span><span class="syntaxdefault"> MINDIAP</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$diaA </span><span class="syntaxkeyword"><</span><span class="syntaxdefault"> MINDIAA</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$krv </span><span class="syntaxkeyword"><</span><span class="syntaxdefault"> MINKRVD</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$krvB</span><span class="syntaxkeyword"><</span><span class="syntaxdefault">MINKRVB</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Mindsteværdier skal overholdes !"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> MB_OK</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> else<br /> $diaP</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $diaA</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $krvD</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $krvB </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> results<br /> end <br /> end</span>
and I get this error message:
Error: #<NoMethodError: undefined method `<' for nil:NilClass>
If I comment out my conditional testing in WHILE and IF then my code runs well !
WHAT IS WRONG HERE ?
-
EDIT access to profil ???
I have no right to edit my signature - this message comes up:
"You are not authorised to define a signature."
What shall I do to get access ?
-
Structure of my Ruby files
I'm working on finding "THE BEST PRACTICE" when talking about structure of rb files and i the long run working towards making my plugins extensions link this link http://sketchupapi.blogspot.com/2011/07/turn-your-plugin-into-extension.html
In the attached file I want to make a module and a class even if I ONLY make it a module it fails - I have commented it out again - what fails is my call to the method draw_pulley in the last few lines (unknown).
If I want this "module and class" structure (to try to do it like "the book") what do I mis then ?
Best regards
KSor, Denmark
What is wrong here WHEN I want this "module & class"-structure
-
New menber
Hey all of you !
I'm Keld from Denmark and I'm new to this Ruby - saw it for the first time about a week ago, but oooooohhh that's what I needed !
I asked for an editor one of the first days - this syntax was driving me crazy but NOW ...
I got the NotePad++ and that's it - really nice work !
Now I'l create a signature
Best regards
KSor, Denmark