[Plugin] TIG-Smart_offset

[Plugin] TIG-Smart_offset

Postby TIG » Thu Dec 20, 2012 9:39 pm

TI-Smart_offset.PNG
TIG (c) 2012-2017
All Rights Reserved.
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.



TIG-Smart_offset.rb

Offsets edges of a specified face by a distance 'smartly'

TIG::Smart_offset.new(face, distance)

Overview:
A +ve distance offsets the face's outer_loop outside of the loop.
A -ve distance offsets the face's outer_loop inside the loop.
If the face's outer_loop perimeter contains a thin inlet or thin peninsula
then twisted loops are avoided and trimmed off, only a single non-twisted
new face and edge-set is created.
New edges crossing other coplanar faces will split them as appropriate.
Holes in the face or unconnected but coplanar faces that overlap with the new
geometry might be 'infilled', just as with the native 'offset'.
On completion it returns an array containing the original face and any new
face[s] created or affected by the creation of the new geometry, or 'nil'
if no face could be created - e.g. the face was too small to contain the
internal offset loop using the given -ve distance.
The new face[s] have the same front/back material and layer as the face
itself.
Some very convoluted faces with 're-entrant' forms and 'inlets' can cause
failures, because a fully 'neatened' set of offset edges cannot be determined...

Usage:

For developers it can be used as a method to call from within their own scripts.
Add a "require 'TIG-Smart_offset.rb'" line into your code to ensure it's
loading, OR adjust the [modified] code to run only within your own Module/Class.
Remember to distribute this file with your scripts, because users probably won't
have it installed.

f = Sketchup.active_model.selection[0] # or other method the define 'f'...
fa = TIG::Smart_offset.new(f, 1.2)

'fa' returns as an array of faces - usually one face - created by the operation.
'f' remains as a reference to the original face,
fa[0] etc is the newly created face -
with a +ve distance fa[0] etc is the outer 'donut' ring ['f' is the inner face],
in the case of a -ve distance it is the inner face ['f' is the outer 'donut']

OR from the 'Tools' menu > 'TIG.Smart_offset'.
OR from the Context-menu > 'TIG.Smart_offset' .
OR from the [activated] Toolbar > 'TIG.Smart_offset'.

Which use the method:
TIG::Smart_offsetter.dialog()

In the dialog you enter the required offset in current units,
[or add a units suffix for non-current dimensions].
A +ve offset is applied outside of the face's outer_loop and a -ve offset is
made inside the face's outer_loop.
It mimics the native offset-tool in most respects, other than removing
many of the spurious twisted offset line/loops.
Curves/Arcs are offset as curves in the new offset outline.
ALL selected faces are offset by the distance specified.
The last used offset distance is remembered during that session.
It is one step undo-able for all offsets.
Do not use with the Outliner open and rolled-down, as this may cause splats!

Version:
1.0 20121221 First issue.
1.1 20121221 Made more robust.
1.2 20121221 Further robustness in enabling/suitable? [thanks to Jim!].
1.3 20121221 Removed 'suitable?' method, to suit MACs, more error traps etc.
1.4 20121222 Validation on applied to PCs, to avoid MAC toolbar glitch,
1.5 20121224 Coding improved for truer, tidier offsets.
1.6 20121225 Curves/Arcs are now offset as curves in the new offset outline.
1.7 20121227 Further glitches and convoluted offsets trapped.
1.8 20121228 Single welded curve loop offsets correctly. Fixed typo in weld.
1.9 20121230 Error in code when called within another script fixed.
2.0 20121231 Further refinements and glitch trapping.
2.1 20121231 Glitch trapping extended to curves.
3.0 20170510 Made compatible with newer versions...

Donations:
By PayPal.com to info @ revitrev.org
11
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby Rich O Brien » Thu Dec 20, 2012 9:44 pm

Merry Xmas to you too.

Nice tool
0
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby Chris Fullmer » Thu Dec 20, 2012 10:00 pm

Awesome TIG! Thanks for this one,

Chris
1
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby alpro » Thu Dec 20, 2012 10:23 pm

Thanks TIG
0

alpro 
Premium Member
Premium Member
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby massimo » Thu Dec 20, 2012 11:05 pm

Merry Christmas TIG. :) :thumb:
0
User avatar
massimo 
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby pilou » Fri Dec 21, 2012 12:26 am

Tahnks for the gift before the end of world ! :fro:

Seems marvellous but...(maybe I miss something :oops:
The bow tie must not be disapear ?
(Normal Offset = Native Offset, Nothing = TIG_Smart_Offset )
Sorry for the inconvenience ! :)

Cool_but.jpg
0
Last edited by pilou on Fri Dec 21, 2012 12:54 am, edited 1 time in total.
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby TIG » Fri Dec 21, 2012 12:54 am

Pilou

There is a Ruby Console error message saying it can't be done [clearly it can !]
I knew there was as reason I had never released this code !
Now I need to find out what's wrong with it ??
Merry Solstice...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby pilou » Fri Dec 21, 2012 12:56 am

Bon courage! :thumb:
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby kargall » Fri Dec 21, 2012 1:11 am

Works very well. Merry Xmas to you too. Thanks ;)
0

kargall 
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby driven » Fri Dec 21, 2012 1:12 am

undefined method `suitable?' for TIG::Smart_offsetter:ModuleError Loading File TIG-Smart_offset.rb
undefined method `suitable?' for TIG::Smart_offsetter:Module

but worked to a degree, the new border and face are separate and I can't seem to get them to merge with the original face?

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] TIG-Smart_offset v1.0 20121221

Postby TIG » Fri Dec 21, 2012 1:32 am

driven wrote:undefined method `suitable?' for TIG::Smart_offsetter:ModuleError Loading File TIG-Smart_offset.rb
undefined method `suitable?' for TIG::Smart_offsetter:Module

but worked to a degree, the new border and face are separate and I can't seem to get them to merge with the original face?

john
Strange there is a method called that ?
It checks selection for suitability and affects how the menu, toolbar and context-menu items display/enabled...
Are you on MAC ?
Was there a line number with that error ?
I'm about to issue v1.1 to resolve Pilou's tolerance issue...
I'll swap some code around to see if making that method earlier fixes it for you...
Let me know whatever you can... :?
If it's still an issue a sample SKP might help...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby TIG » Fri Dec 21, 2012 1:42 am

Here's v1.1 viewtopic.php?p=446462#p446462
It's been made more robust.
It now works on Pilou's problem shapes!
Capture.PNG
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby driven » Fri Dec 21, 2012 2:15 am

Hi Tig,
I'll try the new one but something really odd is going on, and yes I'm on a mac.
2012-12-21 01.06.32 am.png

I used SU to instal, and had line numbers then, so I removed it from 'plugins' to do again, but
this has been uninstalled, moved to trash, emptied trash, restarted computer, but it still there and it works, as well as it did, although sketchup can't find the file.... it's crazy, I don't have hidden files either.

I'll over write with the new
john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby driven » Fri Dec 21, 2012 2:30 am

found it, a new 'finder. replacement doesn't update instantly... bin that
ok no errors. menu cmd works, context cmd work, toolbar cmd dosen't do anything

It works if I split if the validation proc
cmd2=UI::Command.new('TIG.Smart_offset'){self.dialog()}
cmd2.small_icon=File.join(dir, 'TIG-Smart_offset.png')
cmd2.large_icon=File.join(dir, 'TIG-Smart_offset.png')
toolbar=UI::Toolbar.new('TIG.Smart_offset')
toolbar.add_item(cmd2)


john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby Mistro11 » Fri Dec 21, 2012 5:03 am

You have no idea how many times I got frustrated doing an offset and have to get in there and clean up the shape. Thanks TIG!
0
i7-4930k @3.4/3.7GHz, 32Gb RAM, NVidia GTX 980Ti 6Gb, Windows 7 Pro 64bit
Structural Integrity is Not Just Physical...It's in the Design and Purpose
User avatar
Mistro11 
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby jeff hammond » Fri Dec 21, 2012 5:47 am

i'm all greyed out (on two separate computers with different OS & different versions of sketchup on them).. will investigate more tomorrow


smrtoff.png
0
dotdotdot
User avatar
jeff hammond 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby notareal » Fri Dec 21, 2012 7:21 am

Merry Christmas to you too!
0
Welcome to try Thea Render, Thea support | kerkythea.net -team member

notareal 
Thea Render Support
Thea Render Support
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby Jim » Fri Dec 21, 2012 9:27 am

in cmd.set_validation_proc (and other places) you want to give the full scope of the suitable? method since it is being called from SketchUp outside the scope of your module.

Also, combine the MF_ bits.

Code: Select all
cmd=UI::Command.new('TIG.Smart_offset'){self.dialog()}
if TIG::Smart_offsetter.suitable?()
MF_ENABLED
else
MF_DISABLED | MF_GRAYED
end
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby cotty » Fri Dec 21, 2012 9:57 am

Nice gift! Thank you and Merry Christmas! (Are we allowed to use it before 24.12.?)
0
User avatar
cotty 
Top SketchUcator
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby pilou » Fri Dec 21, 2012 9:59 am

Yeeeeeeees! Works like a charm now! :thumb:
You are the Ruby's king! :fro:

And lucky because I can't more test your tricky plugin before the next year! :D

Super_TIG.jpg
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] TIG-Smart_offset v1.1 20121221

Postby TIG » Fri Dec 21, 2012 10:13 am

Jim wrote:in cmd.set_validation_proc (and other places) you want to give the full scope of the suitable? method since it is being called from SketchUp outside the scope of your module.

Also, combine the MF_ bits.

Code: Select all
cmd=UI::Command.new('TIG.Smart_offset'){self.dialog()}
if TIG::Smart_offsetter.suitable?()
MF_ENABLED
else
MF_DISABLED | MF_GRAYED
end
Thanks, knew it was obvious... This only affected MACs though ???
This was collecting dust on a virtual dust, until Pilou reminded me that I'd written it, so sometimes things get 'forgotten'... :roll:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby TIG » Fri Dec 21, 2012 10:26 am

Here's v1.2 viewtopic.php?p=446462#p446462
Further robustness in enabling/disabling/graying and suitable? tests [thanks to Jim!].
Seems to be especially for MACs :D
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby Jim » Fri Dec 21, 2012 10:26 am

TIG wrote:This only affected MACs though ???


I am not sure - it was just a guess and I don't have a Mac. Did you try it? :lol:
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby TIG » Fri Dec 21, 2012 10:30 am

I don't have a MAC either. :?
Driven's reported issue was on a MAC and Jeff had other issues on a MAC too...
Hopefully this recent v1.2 [...20121221b.rbz !] will address the suitable? check and MF_ issues with the menus/toolbar...
It still works fine on a PC, but then v1.1 did too :? :D
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby elmer » Fri Dec 21, 2012 11:22 am

Nice Christmas gift Tig, thanks a lot, it works perfectly on my Mac.
0
User avatar
elmer 
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby alvis » Fri Dec 21, 2012 11:35 am

Thanx TIG
0
User avatar
alvis 
Premium Member
Premium Member
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby guanjin » Fri Dec 21, 2012 3:16 pm

TIG wrote:Here's v1.2 viewtopic.php?p=446462#p446462
Further robustness in enabling/disabling/graying and suitable? tests [thanks to Jim!].
Seems to be especially for MACs :D



TIG: Merry Christmas

TIG.gif
0
I come from China, is to learn
User avatar
guanjin 
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby jeff hammond » Fri Dec 21, 2012 5:51 pm

TIG wrote:Here's v1.2 viewtopic.php?p=446462#p446462
Further robustness in enabling/disabling/graying and suitable? tests [thanks to Jim!].
Seems to be especially for MACs :D


Hi Tig
i'm still getting the same greyed out problem.
is there anything i can type in the console or ?? to help figure out what the problem is?
thanks
0
dotdotdot
User avatar
jeff hammond 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby TIG » Fri Dec 21, 2012 6:02 pm

Is there no difference at all - if you have nothing preselected, or one edge preselected, or one face preselected, or lots of things [including some edges] preselected ?
The menu/toolbar are only enabled if there's at least one face in the current selection.
The context-menu only appears if there's at least one face in the current selection.

Copy/paste+<enter> these into the Ruby Console and report the results:

with nothing preselected TIG::Smart_offsetter.suitable?()
with one edge preselected TIG::Smart_offsetter.suitable?()
with one face preselected TIG::Smart_offsetter.suitable?()
with lots of things [including some edges] preselected TIG::Smart_offsetter.suitable?()

with one edge preselected TIG::Smart_offsetter.dialog()
with one face preselected TIG::Smart_offsetter.dialog()

:?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TIG-Smart_offset v1.2 20121221

Postby jeff hammond » Fri Dec 21, 2012 6:37 pm

oops :oops:
it actually is working now..
it's just the toolbar that remains greyed out at all times but the menu item becomes available once an appropriate selection has been made..

(which, for me personally, is fine.. i more likely than not wont want the toolbar anyway.. i think id use it with a modifier key added to my offset shortcut)
0
dotdotdot
User avatar
jeff hammond 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: clovis sanches, harisanker and 13 guests

Visit our sponsors: