├── .gitignore
├── ArrayBetween.py
├── Crv2ViewLoose.py
├── DynamicCrvOnSrf.py
├── LICENSE
├── OffsetCrvLoose.py
├── ProjectOnSrfLoose.py
├── README.md
├── blocks
├── organizeBlocks.py
└── organizedBlock.py
├── bounding_points.py
├── layout-tools
├── add_detail_scale.py
├── add_partlist.py
├── align_details.gif
├── align_details.py
├── align_dims.gif
├── align_dims.py
├── annotation_balloon.png
├── annotation_balloon.py
├── change_block_description.py
├── change_page_scale.py
├── organize_annotations.py
├── organize_details.py
├── page_scale_helpers.py
├── projected_view.py
├── set_detail_scale.py
├── set_details_scale_to_page_scale.py
├── set_page_and_details_scale.py
└── set_page_scale.py
├── linestyles
├── arrowCurve.py
├── arrowCurve_fenceCurve_multiLineCurve.png
├── fenceCurve.png
├── fenceCurve.py
├── hatchedCurve.py
├── linetypes.gh
├── linetypes.gh.png
├── multiLineCurve.py
└── temp
├── set_gumball.png
├── set_gumball_max.py
├── set_gumball_min.py
├── thin_sheet_metal
├── add_cutters_for_rivets.py
├── add_rivets.py
└── simplified_sheet_metal.gh
└── vray
├── Vray-Tools.rui
├── changeRes.py
├── customRes.py
├── guessHorizontalShift.py
├── moveLight.py
├── reflectLight.py
└── swapRes.py
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | .DS_Store
3 |
--------------------------------------------------------------------------------
/ArrayBetween.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 | """
3 | This script allows you array curves, surfaces and polysurfaces, from object
4 | boundingbox center or corners to a picked point, where the new objects will get
5 | distributed between center or corner and picked point. You will see a dynamic preview
6 | and can change the amount while the preview updates.
7 |
8 | ***********************************
9 | * script written by Gijs de Zwart *
10 | * www.studiogijs.nl *
11 | * April, 2016 *
12 | ***********************************
13 |
14 | """
15 | import Rhino
16 | import rhinoscriptsyntax as rs
17 | from System.Drawing import Color
18 | import scriptcontext as sc
19 |
20 |
21 | def ArrayBetween():
22 |
23 | def OnDynamicDraw(sender, e):
24 | i=optBasePoint[0]
25 | pts=[]
26 | count=optInt.CurrentValue
27 | if i==0:#center
28 | basept.X = center.X
29 | basept.Y = center.Y
30 | if i==1:#lowerleft
31 | basept.X = center.X-width/2
32 | basept.Y = center.Y-depth/2
33 | if i==2:#upperleft
34 | basept.X = center.X-width/2
35 | basept.Y = center.Y+depth/2
36 | if i==3:#lowerright
37 | basept.X = center.X+width/2
38 | basept.Y = center.Y-depth/2
39 | if i==4:#upperright
40 | basept.X = center.X+width/2
41 | basept.Y = center.Y+depth/2
42 | vec = e.CurrentPoint - basept
43 |
44 |
45 | gp.SetBasePoint(basept, False)
46 | line = Rhino.Geometry.Line(basept, e.CurrentPoint)
47 | curve=line.ToNurbsCurve()
48 | params=curve.DivideByCount(count-1,True)
49 | for param in params:
50 | pts.append(line.PointAt(param))
51 |
52 | length = vec.Length
53 | dist=length/(count-1)
54 | vec.Unitize()
55 |
56 | for i in range(1,count):
57 | translate = vec * i * dist
58 | xf = Rhino.Geometry.Transform.Translation(translate)
59 | newobj=obj.Duplicate()
60 | newobj.Transform(xf)
61 | if obj.ObjectType==Rhino.DocObjects.ObjectType.Curve:
62 | e.Display.DrawCurve(newobj, Color.LightCyan, 2)
63 | if obj.ObjectType==Rhino.DocObjects.ObjectType.Brep:
64 | e.Display.DrawBrepWires(newobj, Color.LightCyan)
65 | e.Display.DrawLine(line, Color.Blue, 2)
66 |
67 |
68 | def getPoint():
69 | while True:
70 | result = gp.Get()
71 | if result == Rhino.Input.GetResult.Point:
72 | count=optInt.CurrentValue
73 | line = Rhino.Geometry.Line(center, gp.Point())
74 | curve=line.ToNurbsCurve()
75 | params=curve.DivideByCount(count-1,True)
76 | pts=[]
77 | for param in params:
78 | pts.append(line.PointAt(param))
79 | vec = gp.Point() - basept
80 | length = vec.Length
81 | dist=length/(count-1)
82 | vec.Unitize()
83 |
84 | for i in range(1,count):
85 | translate = vec * i * dist
86 | xf = Rhino.Geometry.Transform.Translation(translate)
87 | newobj=obj.Duplicate()
88 | newobj.Transform(xf)
89 | if obj.ObjectType==Rhino.DocObjects.ObjectType.Curve:
90 | sc.doc.Objects.AddCurve(newobj)
91 | if obj.ObjectType==Rhino.DocObjects.ObjectType.Brep:
92 | sc.doc.Objects.AddBrep(newobj)
93 | sc.doc.Views.Redraw()
94 | elif result == Rhino.Input.GetResult.Option:
95 | optionindex = gp.Option().CurrentListOptionIndex
96 | optBasePoint[0]=optionindex
97 |
98 | getPoint()
99 | break
100 |
101 |
102 | docobj = rs.GetObject("select object to array", 28)
103 | if not docobj: return
104 | if rs.IsCurve(docobj):
105 | obj=rs.coercecurve(docobj)
106 | if rs.IsBrep(docobj):
107 | obj=rs.coercebrep(docobj)
108 | if not obj:
109 | return
110 |
111 | plane=Rhino.Geometry.Plane.WorldXY
112 | bb=obj.GetBoundingBox(plane)
113 | if bb==None:
114 | print "can't calculate boundingbox"
115 | return
116 | center = bb.Center
117 |
118 | basept = bb.Center
119 |
120 | minimum = bb.Min
121 | maximum = bb.Max
122 |
123 | center.Z=minimum.Z
124 | width = maximum.X-minimum.X
125 | depth = maximum.Y-minimum.Y
126 |
127 |
128 | gp=Rhino.Input.Custom.GetPoint()
129 | gp.SetCommandPrompt("point to array to / distance")
130 | optInt=Rhino.Input.Custom.OptionInteger(3,3,999)
131 | gp.AddOptionInteger("Count",optInt)
132 | basepoints=["center", "lower_left","upper_left","lower_right","upper_right"]
133 | gp.AddOptionList("basepoint", basepoints, 0)
134 | optBasePoint=[0]#equal to index 0 of basepoints option
135 |
136 | gp.DynamicDraw += OnDynamicDraw
137 | getPoint()
138 | if( __name__ == "__main__" ):
139 | ArrayBetween()
140 |
--------------------------------------------------------------------------------
/Crv2ViewLoose.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | This script does what the name says: it allows you make a curve from 2 views loosely.
4 | This means the resulting curve has the same structure and degree, and same amount
5 | of control points as the original curves. Points don't need to be aligned exactly,
6 | the script will average points out it the flow direction of the curves.
7 |
8 | ***********************************
9 | * script written by Gijs de Zwart *
10 | * www.studiogijs.nl *
11 | * March, 2016 *
12 | ***********************************
13 |
14 | """
15 |
16 | import rhinoscriptsyntax as rs
17 |
18 | def Crv2ViewLoose():
19 | curve1 = rs.GetObject("select first curve", rs.filter.curve)
20 | if curve1 !=None:
21 | rs.LockObject(curve1)
22 | curve2 = rs.GetObject("select second curve", rs.filter.curve)
23 | if curve1==None or curve2==None:
24 | return
25 |
26 | degree1=rs.CurveDegree(curve1)
27 | degree2=rs.CurveDegree(curve2)
28 | pts1 = rs.CurvePoints(curve1)
29 | pts2 = rs.CurvePoints(curve2)
30 | error=False
31 | errors=[]
32 | if rs.IsPolyCurve(curve1) or rs.IsPolyCurve(curve2):
33 | errors.append("Error: This script only works for single open curves")
34 | error=True
35 | if not rs.IsCurvePlanar(curve1) or not rs.IsCurvePlanar(curve2):
36 | errors.append("Error: One or more of the input curves is not planar.")
37 | error=True
38 | if rs.IsCurvePeriodic(curve1) or rs.IsCurvePeriodic(curve2):
39 | errors.append("Error: This script only works with open curves")
40 | error=True
41 | if len(pts1)!=len(pts2):
42 | errors.append("Error: Input curves need to have same amount of control points")
43 | error=True
44 | if rs.CurveDegree(curve1) != rs.CurveDegree(curve2):
45 | errors.append("Error: Input curves need to be of same degree")
46 | error=True
47 | if error:
48 | for err in errors:
49 | print err
50 | rs.UnlockObject(curve1)
51 | return
52 |
53 | top=0
54 | right=0
55 | front=0
56 | if rs.CurvePlane(curve1).ZAxis[2]!=0:#top view curve
57 | top=1
58 |
59 | if rs.CurvePlane(curve2).ZAxis[2]!=0:#top view curve
60 | top=2
61 |
62 | if rs.CurvePlane(curve1).ZAxis[0]!=0:#right view curve
63 | right=1
64 |
65 | if rs.CurvePlane(curve2).ZAxis[0]!=0:#right view curve
66 | right=2
67 |
68 | if rs.CurvePlane(curve1).ZAxis[1]!=0:#front view curve
69 | front=1
70 |
71 | if rs.CurvePlane(curve2).ZAxis[1]!=0:#front view curve
72 | front=2
73 |
74 |
75 | pts3=[]#array to store the points for the new curve
76 | if top==1 and right==2:
77 | for i in range(0,len(pts1)):
78 | pts1[i][2] = pts2[i][2]
79 | pts1[i][1] = (pts1[i][1]+pts2[i][1])/2 #average out y-coordinate of each point
80 | pts3.append(pts1[i])
81 | if top==2 and right==1:
82 | for i in range(0,len(pts1)):
83 | pts2[i][2] = pts1[i][2]
84 | pts2[i][1] = (pts1[i][1]+pts2[i][1])/2 #average out y-coordinate of each point
85 | pts3.append(pts2[i])
86 | if top==1 and front==2:
87 | for i in range(0,len(pts1)):
88 | pts1[i][2] = pts2[i][2]
89 | pts1[i][0] = (pts1[i][0]+pts2[i][0])/2 #average out x-coordinate of each point
90 | pts3.append(pts1[i])
91 | if top==2 and front==1:
92 | for i in range(0,len(pts1)):
93 | pts2[i][2] = pts1[i][2]
94 | pts2[i][0] = (pts1[i][0]+pts2[i][0])/2 #average out x-coordinate of each point
95 | pts3.append(pts2[i])
96 | rs.UnlockObject(curve1)
97 |
98 | if (right==0 and front==0) or (top==0 and right==0) or (top==0 and front==0):
99 | print "Error: Curves need to be placed on orthogonal views"
100 | return
101 | else:
102 |
103 | rs.AddCurve(pts3,degree1)
104 |
105 | if __name__ == '__main__':
106 | Crv2ViewLoose()
--------------------------------------------------------------------------------
/DynamicCrvOnSrf.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | This script allows you draw a controlpoint curve on a surface, where you can
4 | dynamically change the amount of points and see a preview of the resulting
5 | curve while drawing.
6 |
7 | ***********************************
8 | * script written by Gijs de Zwart *
9 | * www.studiogijs.nl *
10 | * April, 2016 *
11 | ***********************************
12 |
13 | """
14 |
15 | import Rhino
16 | import rhinoscriptsyntax as rs
17 | from System.Drawing import Color
18 | import scriptcontext as sc
19 |
20 | def DynamicCrvOnSrf():
21 |
22 | def drawMyCurve(sender,e):
23 |
24 | points[-1]=e.CurrentPoint#change last point to CurrentPoint
25 | pts = [points[i] for i in xrange(len(points))]
26 | curve=rhsrf.InterpolatedCurveOnSurface(points,0.01)
27 | if curve==None:
28 | del pts[-1]
29 | curve=rhsrf.InterpolatedCurveOnSurface(pts,0.01)
30 | if curve:
31 | nc = curve.ToNurbsCurve()
32 | ptCount=optInt.CurrentValue
33 | nc=nc.Rebuild(ptCount,3, True)
34 | ncpoints = [nc.Points[i].Location for i in xrange(nc.Points.Count)]
35 | e.Display.DrawCurve(nc, Color.LightCyan,2)
36 | e.Display.DrawPoints(ncpoints,Rhino.Display.PointStyle.Simple,5,Color.Cyan)
37 | e.Display.DrawPoints(points,Rhino.Display.PointStyle.X,1,Color.Blue)
38 |
39 | def getPoint():
40 | if points!=[] and len(points)==4:
41 | gp.AddOption("Close")
42 | while True:
43 | result = gp.Get()
44 | if result == Rhino.Input.GetResult.Point:
45 | gp.AcceptUndo(True)
46 | gp.SetCommandPrompt("Next point")
47 | pt=gp.Point()
48 | newpoint=rs.AddPoint(pt)
49 | snapPoints.append(newpoint)
50 | #append first picked point
51 | if points==[]:
52 | points.append(pt)
53 | gp.DynamicDraw+=drawMyCurve
54 | #check if next picked point is same as previous
55 | if len(points)>1:
56 | a=round(points[-1].X,2)
57 | b=round(points[-2].X,2)
58 | if a==b:
59 | del points[-1]
60 | #add empty point to list
61 | #will get assigned in drawMyCurve()
62 | points.append(Rhino.Geometry.Point3d)
63 |
64 | #recursion: getpoint calling itself if a point has been picked:
65 | getPoint()
66 | elif result == Rhino.Input.GetResult.Option:
67 | #go back to point selection mode
68 | if gp.OptionIndex()==1:
69 | getPoint()
70 | elif gp.OptionIndex()==2:
71 | #close the curve
72 | del points[-1]
73 | ptCount=optInt.CurrentValue
74 | pt=points[0]
75 | #check if the last point is already 'closing' the curve
76 | a=round(points[-1].X,2)
77 | b=round(points[0].X,2)
78 | if a==b:
79 | del points[-1]
80 | points.append(pt)
81 | rs.DeleteObjects(snapPoints)
82 | newcrv=rs.AddInterpCrvOnSrf(srf, points)
83 | rs.RebuildCurve(newcrv,3,ptCount)
84 | sc.doc.Views.Redraw()
85 |
86 | elif result == Rhino.Input.GetResult.Undo:
87 | if len(points)>1:
88 | del points[-2]
89 | rs.DeleteObject(snapPoints[-1])
90 | del snapPoints[-1]
91 | if len(points)<=1:
92 | gp.AcceptUndo(False)
93 | getPoint()
94 | #pressing spacebar, enter
95 | elif result == Rhino.Input.GetResult.Nothing and len(points)>2:#2 picked points +1 temporary point
96 | #remove last added preview point
97 | del points[-1]
98 | ptCount=optInt.CurrentValue
99 | rs.DeleteObjects(snapPoints)
100 | newcrv=rs.AddInterpCrvOnSrf(srf, points)
101 | rs.RebuildCurve(newcrv,3,ptCount)
102 | sc.doc.Views.Redraw()
103 | #pressing esc
104 | else:
105 | rs.DeleteObjects(snapPoints)
106 | break
107 |
108 | srf=rs.GetObject("Select surface to draw curve on", rs.filter.surface)
109 | if srf==None:
110 | return
111 | rhsrf=rs.coercesurface(srf)
112 | gp=Rhino.Input.Custom.GetPoint()
113 | gp.SetCommandPrompt("Start of Curve")
114 | gp.Constrain(rhsrf, False)
115 | gp.AcceptNothing(True)
116 | Rhino.ApplicationSettings.SmartTrackSettings.UseSmartTrack=False
117 | points=[]
118 | snapPoints=[]
119 | optInt=Rhino.Input.Custom.OptionInteger(20,4,100)
120 | gp.AddOptionInteger("ptCount",optInt)
121 | getPoint()
122 |
123 | if( __name__ == "__main__" ):
124 | DynamicCrvOnSrf()
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/OffsetCrvLoose.py:
--------------------------------------------------------------------------------
1 | """
2 | This script does what the name says: it allows you to offset a curve loosely.
3 | This means the offset curve has the same structure and degree, and same amount
4 | of control points as the original curve.
5 | Option to offset both sides.
6 |
7 | ***********************************
8 | * script written by Gijs de Zwart *
9 | * www.studiogijs.nl *
10 | * March, 2016 *
11 | ***********************************
12 |
13 | """
14 |
15 |
16 | import rhinoscriptsyntax as rs
17 | import Rhino
18 | import scriptcontext as sc
19 |
20 | def OffsetCrvLoose():
21 |
22 | crv=rs.GetObject("select curve to offset loosely",rs.filter.curve, True)
23 | if crv==None:
24 | return
25 | if not rs.IsCurvePlanar(crv):
26 | print "Sorry, but that curve is not planar."
27 | return
28 | if rs.IsPolyCurve(crv):
29 | print "This simple script works only for single open or closed curves"
30 | return
31 | offset=rs.GetReal("offset amount",5)
32 |
33 | if offset==None or offset==0:
34 | return
35 | both_sides=rs.GetBoolean("Offset both sides?",["both_sides","off","on"], False)[0]
36 | bPeriodic=False
37 | #rs.EnableRedraw(False)
38 | pts=rs.CurvePoints(crv)
39 | degree=rs.CurveDegree(crv)
40 | if rs.IsCurvePeriodic(crv):
41 | pts=rs.CullDuplicatePoints(pts,0.01)
42 | bPeriodic=True
43 | offset_pts=[]
44 | offset_pts2=[]#if both_sides=true
45 | plane=rs.CurvePlane(crv)
46 | axis=plane.ZAxis
47 | for pt in pts:
48 | cp=rs.CurveClosestPoint(crv,pt)
49 | v=rs.CurveTangent(crv,cp)
50 | v=rs.VectorUnitize(v)
51 | v*=offset
52 | v=rs.VectorRotate(v,90,axis)
53 | pt_=rs.AddPoint(pt)
54 | #create points for offset on one side of the curve
55 | movedpt=rs.MoveObject(pt_,v)
56 | newpt=rs.coerce3dpoint(movedpt)
57 | offset_pts.append(newpt)
58 | #create points for offset on other side of the curve
59 | movedpt=rs.MoveObject(pt_,-2*v)
60 | newpt=rs.coerce3dpoint(movedpt)
61 | offset_pts2.append(newpt)
62 | rs.DeleteObject(pt_)
63 | nc = Rhino.Geometry.NurbsCurve.Create(bPeriodic,degree,offset_pts)
64 | nc2 = Rhino.Geometry.NurbsCurve.Create(bPeriodic,degree,offset_pts2)
65 |
66 | if not both_sides:
67 | if nc.GetLength(0.1)>nc2.GetLength(0.1):#get the longest curve...
68 | if offset>0:#...and add it to the document for positive offsets...
69 | sc.doc.Objects.AddCurve(nc)
70 | else:#...or the shortest for negative offsets.
71 | sc.doc.Objects.AddCurve(nc2)
72 | else:
73 | if offset>0:
74 | sc.doc.Objects.AddCurve(nc2)
75 | else:
76 | sc.doc.Objects.AddCurve(nc)
77 | else:#add both curves to the document
78 | sc.doc.Objects.AddCurve(nc)
79 | sc.doc.Objects.AddCurve(nc2)
80 |
81 | rs.EnableRedraw(True)
82 | sc.doc.Views.Redraw()
83 | if __name__ == '__main__':
84 | OffsetCrvLoose()
85 |
--------------------------------------------------------------------------------
/ProjectOnSrfLoose.py:
--------------------------------------------------------------------------------
1 | """
2 | This script does what the name says: it allows you to loosly
3 | project a curve on a surface. This means the projected curve has the same
4 | structure and degree and same amount of control points as the original curve.
5 |
6 | ***********************************
7 | * script written by Gijs de Zwart *
8 | * www.studiogijs.nl *
9 | * March, 2016 *
10 | ***********************************
11 |
12 | """
13 |
14 | import rhinoscriptsyntax as rs
15 | import Rhino
16 | import scriptcontext as sc
17 |
18 | def ProjectOnSrfLoose():
19 | crv=rs.GetObject("select curve to loosely project",rs.filter.curve)
20 | srf=rs.GetObject("Select surface to loosely project onto", rs.filter.surface)
21 | if crv==None or srf==None:
22 | return
23 | degree=rs.CurveDegree(crv)
24 | bPeriodic=False
25 | pts=rs.CurvePoints(crv)
26 | if rs.IsCurvePeriodic(crv):
27 | pts=rs.CullDuplicatePoints(pts,0.01)
28 | bPeriodic=True
29 |
30 | pts_projected=[]
31 | curveplane=rs.CurvePlane(crv)
32 | projection_dir=curveplane.ZAxis
33 |
34 | for pt in pts:
35 |
36 | pp=rs.ProjectPointToSurface(pt,srf,projection_dir)
37 | if len(pp)>0:
38 | pt_projected=pp[0]
39 | pts_projected.append(pt_projected)
40 | if len(pts_projected)<=2:
41 | return
42 | if len(pts_projected)=1.0:
42 | text = str(int(ratio)) + ":1"
43 | else:
44 | text = "1:" + str(int(1/ratio))
45 | if page_scale == text:
46 | print ("At least one detail has the same scale as the page scale, no scale info to this detail was added.")
47 | return
48 | else:
49 | pt = [0,0,0]
50 | pt[0] = detail.Geometry.GetBoundingBox(Rhino.Geometry.Plane.WorldXY).Min.X+3
51 | pt[1] = detail.Geometry.GetBoundingBox(Rhino.Geometry.Plane.WorldXY).Min.Y+3
52 | psh.set_detail_scale(detail, ratio)
53 | id = str(detail.Id)
54 | p="%"
55 | scale = '%s%s' % (p, id, p)
56 |
57 | text = "detail (scale " +scale+ ")"
58 |
59 | sc.doc.Views.ActiveView = pageview
60 | rs.AddText(text, pt, height=2.0, font = 'Courier new', justification = 65537)#bottom left
61 |
62 |
63 | if __name__ == '__main__':
64 | main()
--------------------------------------------------------------------------------
/layout-tools/add_partlist.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 | import scriptcontext as sc
3 | import Rhino
4 | from System.Drawing import Color as Col
5 |
6 | def main():
7 | """
8 | Creates a part list for all blocks in a document. Numbers will correspond with
9 | balloons, but balloons don't need to be present for the table to be generated
10 |
11 | version 1.3
12 | www.studiogijs.nl
13 |
14 | version 1.1 adds table heading
15 | version 1.2 option for choosing between all or only top level blocks
16 | version 1.3 adds block description. Use change_block_description.py
17 | or change in block manager
18 |
19 | """
20 | t = sc.sticky['top_level_only'] if sc.sticky.has_key('top_level_only') else False #0 = top level only, 1= all blocks
21 | if t==None:
22 | t=False
23 | top_level_only = rs.GetBoolean("annotate top level blocks only?", ["top_level_only", "yes", "no"],t)
24 | if not top_level_only:
25 | return
26 | sc.sticky['top_level_only'] = top_level_only[0]
27 |
28 |
29 | previous_layer = rs.CurrentLayer()
30 | #check if layer 'annotation' exist, else create it
31 | if not rs.IsLayer("annotation"): rs.AddLayer("annotation")
32 | rs.LayerColor("annotation",Col.Black)
33 |
34 | rs.CurrentLayer("annotation")
35 |
36 | groups = sc.doc.ActiveDoc.Groups
37 | partlist = []
38 |
39 | blocknames=get_block_names()
40 | if not blocknames:
41 | print ("This file does not contain block items (titleblock will be ignored)")
42 | return
43 | #add headings
44 | texts = ["ITEM", "PART NAME","DESCR", "QTY"]
45 | partlist.append(texts)
46 | texts=[]
47 | for block_nr, blockname in enumerate(blocknames,1):
48 | texts.append(str(block_nr))
49 | texts.append(blockname)
50 | description = rs.BlockDescription(blockname)
51 | if description is None:
52 | description = ""
53 | texts.append(description)
54 | blockcount = get_block_count(blockname)
55 | texts.append(str(blockcount))
56 | partlist.append(texts)
57 | texts=[]
58 | create_table(partlist)
59 | #change back to previous layer
60 | rs.CurrentLayer(previous_layer)
61 |
62 | def get_block_index(blockname):
63 | blocknames = get_block_names()
64 | if blocknames:
65 | return blocknames.index(blockname)
66 | return False
67 | def get_block_count(blockname):
68 | #blockcount = sc.doc.ActiveDoc.InstanceDefinitions.ActiveCount
69 | blocks = sc.doc.ActiveDoc.InstanceDefinitions
70 | blocknames=[]
71 | for block in blocks:
72 | if block.Name==blockname:
73 | return block.UseCount()
74 | return False
75 |
76 | def get_block_names():
77 |
78 | blocks = sc.doc.ActiveDoc.InstanceDefinitions
79 | blocknames=[]
80 | for block in blocks:
81 | if block.Name!= None and not block.Name.__contains__("titleblock"):
82 | if rs.IsBlockInUse(block.Name, where_to_look=sc.sticky['top_level_only']):
83 | blocknames.append(block.Name)
84 |
85 | if len(blocknames)>0:
86 | return blocknames
87 | return False
88 | def get_block_descriptions(blocknames):
89 | descriptions = []
90 | for blockname in blocknames:
91 | description = rs.BlockDescription(blockname)
92 | if description is None:
93 | description = ""
94 | descriptions.append(description)
95 | return descriptions
96 |
97 | def create_table(partlist):
98 | g = rs.GroupNames()
99 | if not g or not "partlistgroup" in g:
100 | rs.AddGroup("partlistgroup")
101 | #clean the group
102 | group= sc.doc.Groups.FindName("partlistgroup")
103 | objs = sc.doc.ActiveDoc.Groups.GroupMembers(group.Index)
104 | rs.DeleteObjects(objs)
105 | #base table width on largest name
106 | blocknames = get_block_names()
107 | twidth = 3 + len(max(blocknames, key = len))*2.1
108 | desc = 3 + len(max(get_block_descriptions(blocknames), key = len))*2.1
109 | if desc < 3+ 5*2.1:
110 | desc = 3+ 5*2.1
111 | def addTexts(texts, y):
112 | for i,text in enumerate(texts):
113 | if i==0:
114 | a=10
115 | just = Rhino.Geometry.TextJustification.BottomRight
116 |
117 | elif i==1:
118 | a=13.5
119 | just = Rhino.Geometry.TextJustification.BottomLeft
120 | elif i==2:
121 | a=13.5+twidth
122 | just = Rhino.Geometry.TextJustification.BottomLeft
123 | else:
124 | a=20+twidth+desc
125 | just = Rhino.Geometry.TextJustification.BottomRight
126 | plane = Rhino.Geometry.Plane.WorldXY
127 | plane.Origin = Rhino.Geometry.Point3d(a, y-4, 0)
128 |
129 | textobject = sc.doc.Objects.AddText(text, plane, 2.0 ,'Courier New', False, False, just)
130 | rs.AddObjectToGroup(textobject, "partlistgroup")
131 |
132 | def get_partlist_alignment():
133 |
134 |
135 | point = Rhino.Geometry.Point3d(0,0,0)
136 | listValues = "LowerLeft", "LowerRight", "UpperLeft", "UpperRight"
137 | listIndex = 1
138 | gp = Rhino.Input.Custom.GetPoint()
139 | gp.SetCommandPrompt("Choose alignment and insertion point")
140 | opList = gp.AddOptionList("Alignment", listValues, listIndex)
141 | while True:
142 | get_rc = gp.Get()
143 | if gp.CommandResult()!=Rhino.Commands.Result.Success:
144 | return point, 0
145 | if get_rc==Rhino.Input.GetResult.Point:
146 | point = gp.Point()
147 |
148 | elif get_rc==Rhino.Input.GetResult.Option:
149 | if gp.OptionIndex()==opList:
150 | listIndex = gp.Option().CurrentListOptionIndex
151 | continue
152 | break
153 | return point, listIndex
154 |
155 | def add_borders(i,y):
156 |
157 | start = Rhino.Geometry.Point3d(0,y-6,0)
158 | end = Rhino.Geometry.Point3d(22+twidth+desc,y-6,0)
159 | line = sc.doc.Objects.AddLine(start, end) #bottom border
160 | rs.AddObjectToGroup(line, "partlistgroup")
161 | if i==0:
162 | #add top border
163 | trans = Rhino.Geometry.Transform.Translation(0,6,0)
164 | h_line = Rhino.Geometry.Line(start,end)
165 | h_line.Transform(trans)
166 | line = sc.doc.Objects.AddLine(h_line)
167 | rs.AddObjectToGroup(line, "partlistgroup")
168 | #add vertical lines
169 | v_start = Rhino.Geometry.Point3d(0,y,0)
170 | v_end = Rhino.Geometry.Point3d(0,y-6,0)
171 |
172 | v_line = Rhino.Geometry.Line(v_start,v_end)
173 | line = sc.doc.Objects.AddLine(v_line)
174 | rs.AddObjectToGroup(line, "partlistgroup")
175 |
176 | trans = Rhino.Geometry.Transform.Translation(12,0,0)
177 | v_line.Transform(trans)
178 | line = sc.doc.Objects.AddLine(v_line)
179 | rs.AddObjectToGroup(line, "partlistgroup")
180 |
181 | trans = Rhino.Geometry.Transform.Translation(twidth,0,0)
182 | v_line.Transform(trans)
183 | line = sc.doc.Objects.AddLine(v_line)
184 | rs.AddObjectToGroup(line, "partlistgroup")
185 |
186 | trans = Rhino.Geometry.Transform.Translation(desc,0,0)
187 | v_line.Transform(trans)
188 | line = sc.doc.Objects.AddLine(v_line)
189 | rs.AddObjectToGroup(line, "partlistgroup")
190 |
191 | trans = Rhino.Geometry.Transform.Translation(10,0,0)
192 | v_line.Transform(trans)
193 | line = sc.doc.Objects.AddLine(v_line)
194 | rs.AddObjectToGroup(line, "partlistgroup")
195 |
196 | y = len(partlist)*6
197 | #get insertion point
198 | point, listIndex = get_partlist_alignment()
199 | if point:
200 | target = Rhino.Geometry.Point3d(0,0,0)
201 | if listIndex == 0: #lower left
202 | target[0] = point[0]
203 | target[1] = point[1]
204 | elif listIndex == 1: #lower right
205 | target[0] =point[0]-(22+twidth+desc)
206 | target[1] = point[1]
207 | elif listIndex == 2: #upper left
208 | target[0] = point[0]
209 | target[1] = point[1]-len(partlist)*6
210 | else: #upper right
211 | target[0] =point[0]-(22+twidth+desc)
212 | target[1] = point[1]-len(partlist)*6
213 |
214 | for i, texts in enumerate(partlist):
215 | addTexts(texts, y)
216 | add_borders(i, y)
217 | y-=6
218 |
219 | group= sc.doc.Groups.FindName("partlistgroup")
220 | objs = sc.doc.ActiveDoc.Groups.GroupMembers(group.Index)
221 | rs.MoveObjects(objs, (target))
222 |
223 |
224 |
225 |
226 | if __name__ == '__main__':
227 | main()
--------------------------------------------------------------------------------
/layout-tools/align_details.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/layout-tools/align_details.gif
--------------------------------------------------------------------------------
/layout-tools/align_details.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 |
5 | def align_details():
6 | """
7 | This script will align a detail to another detail on page.
8 | It can match top <-> front both ways
9 | It can match front <-> right both ways
10 | The detail border will remain unaffected, in other words, it will be moved too.
11 | version 1.3
12 | update 1.1: bug fixes, page refresh Rhino 7
13 | update 1.2: added matching left to front
14 | update 1.3: added matching of other orthogonal views
15 |
16 | www.studiogijs.nl
17 | """
18 | #set focus back to page
19 | pageview = sc.doc.Views.ActiveView
20 | if type(pageview) != Rhino.Display.RhinoPageView:
21 | print ("This tool only works in layout space.")
22 | return
23 | pageview.SetPageAsActive()
24 |
25 | child = rs.GetObject("select detail to change")
26 | DC = rs.coercerhinoobject(child)
27 | if type(DC) !=Rhino.DocObjects.DetailViewObject:
28 | return
29 |
30 | parent = rs.GetObject("select detail to match to")
31 | DP = rs.coercerhinoobject(parent)
32 | if type(DP) !=Rhino.DocObjects.DetailViewObject:
33 | return
34 |
35 | def align(DP,DC):
36 | if DP.DetailGeometry.IsParallelProjection:
37 | scale = DP.DetailGeometry.PageToModelRatio
38 | tP = DP.PageToWorldTransform
39 | else:
40 | return False
41 | if DC.DetailGeometry.IsParallelProjection:
42 | sc.doc.Views.ActiveView.SetActiveDetail(DC.Id)
43 |
44 | #check if right type of viewports are being attempted to match
45 | if (DP.Viewport.CameraZ.Z == 1 and DC.Viewport.CameraZ.Y == -1): #match front to top
46 | vertical = True
47 | elif (DC.Viewport.CameraZ.Z == 1 and DP.Viewport.CameraZ.Y == -1): #match top to front
48 | vertical = True
49 | elif (DP.Viewport.CameraZ.Y == -1 and DC.Viewport.CameraZ.X == 1): #match right to front
50 | vertical = False
51 | elif (DC.Viewport.CameraZ.Y == -1 and DP.Viewport.CameraZ.X == 1): #match front to right
52 | vertical = False
53 | elif (DP.Viewport.CameraZ.Y == -1 and DC.Viewport.CameraZ.X == -1): #match left to front
54 | vertical = False
55 | elif (DC.Viewport.CameraZ.Y == -1 and DP.Viewport.CameraZ.X == -1): #match front to left
56 | vertical = False
57 | elif (DP.Viewport.CameraZ.X == 1 and DC.Viewport.CameraZ.Y == 1): #match back to right
58 | vertical = False
59 | elif (DP.Viewport.CameraZ.Y == 1 and DC.Viewport.CameraZ.X == 1): #match right to back
60 | vertical = False
61 | elif (DP.Viewport.CameraZ.Y == 1 and DC.Viewport.CameraZ.X == -1): #match left to back
62 | vertical = False
63 | elif (DP.Viewport.CameraZ.X == -1 and DC.Viewport.CameraZ.Y == 1): #match back to left
64 | vertical = False
65 | else:
66 | return False
67 | #now it is safe to change the scale
68 | DC.DetailGeometry.SetScale(1, sc.doc.ModelUnitSystem, scale, sc.doc.PageUnitSystem)
69 | DC.CommitChanges()
70 | tC = DC.PageToWorldTransform
71 | vh = Rhino.Geometry.Vector3d(-(tP.M03*scale - tC.M03*scale),0,0)
72 | vv = Rhino.Geometry.Vector3d(0, -(tP.M23*scale - tC.M23*scale),0)
73 |
74 | if vertical:
75 | t = Rhino.Geometry.Transform.Translation(vh)#align horizontal
76 | else:
77 | t = Rhino.Geometry.Transform.Translation(vv)#align vertical
78 | DC.Geometry.Transform(t)
79 | DC.CommitChanges()
80 |
81 | else:
82 | return False
83 | return True
84 |
85 | rc = align(DP,DC)
86 | if not rc:
87 | print ("These two viewports cannot be matched")
88 | sc.doc.Views.ActiveView.SetPageAsActive()
89 | sc.doc.Views.Redraw()
90 |
91 | align_details()
--------------------------------------------------------------------------------
/layout-tools/align_dims.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/layout-tools/align_dims.gif
--------------------------------------------------------------------------------
/layout-tools/align_dims.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 | import Rhino
3 | import scriptcontext as sc
4 |
5 | def align_dims():
6 | if not sc.doc.Views.ActiveView.ActiveViewport.CameraZ == Rhino.Geometry.Plane.WorldXY.ZAxis:
7 | print("this works only in top view (world XY)")
8 | return
9 |
10 | """
11 | align vertical dimensions horizontally or horizontal dimensions vertically
12 | version 1.0
13 | www.studiogijs.nl
14 | """
15 |
16 | dims = rs.GetObjects("select dims to align", preselect = True, filter = 512)
17 | if not dims:
18 | return
19 | p_ref = rs.GetPoint("set basepoint for the dimensions", in_plane = True)
20 | if not p_ref:
21 | return
22 | p_ref = rs.coerce3dpoint(p_ref)
23 |
24 | dims = [dim for dim in dims if rs.IsText(dim)==False]
25 |
26 | purge_before = False
27 | for dim in dims:
28 | has_history = sc.doc.Objects.Find(dim).HasHistoryRecord()
29 | if has_history:
30 | print("One or more dimensions have history enabled, and cannot be changed")
31 | purge_before = rs.GetBoolean("Purge the history of these dims before continuing?", ["Purge", "no", "yes"], False)
32 |
33 | break
34 | if purge_before:
35 | rs.UnselectAllObjects()
36 | rs.SelectObjects(dims)
37 | rs.Command("_HistoryPurge")
38 |
39 | dims = [rs.coercerhinoobject(dim) for dim in dims]
40 | for dim in dims:
41 |
42 | vertical=False
43 | horizontal=False
44 | rc, e1, e2, a1, a2, dp, tp = dim.Geometry.Get3dPoints()
45 | if not rc:
46 | return
47 | #check arrow endpoints to see if dim is vertical or horizontal
48 | if a1.Y == a2.Y: horizontal=True
49 | if a1.X == a2.X: vertical=True
50 |
51 | if not (horizontal or vertical): continue #next dimension
52 |
53 | #make sure all points are set relative to e1
54 | #for SetLocations method we need positions of dimension
55 | #extension lines and text position
56 | tp-=e1
57 | p_r=p_ref-e1
58 | e2-=e1
59 | if horizontal:
60 | #make 2dpoints for setting the new location
61 | #sometimes dimension plane is inverted
62 | #depending on where the endpoints wer picked
63 | px = dim.Geometry.Plane.XAxis.X #plane x-axis is (1,0,0) or (-1,0,0)
64 | py = dim.Geometry.Plane.YAxis.Y #plane y-axis is (0,1,0) or (0,-1,0)
65 | dp_new = Rhino.Geometry.Point2d(tp.X*px, p_r.Y*py)
66 | e1_new = Rhino.Geometry.Point2d(0, 0)
67 | e2_new = Rhino.Geometry.Point2d(e2.X*px, e2.Y*py)
68 | elif vertical:
69 | #make 2dpoints for setting the new location
70 | #notice that vertical dimensions have their plane rotated 90 degrees
71 | #sometimes dimension plane is inverted
72 | px = dim.Geometry.Plane.XAxis.Y #plane x-axis is (0,-1,0) or (0,1,0)
73 | py = dim.Geometry.Plane.YAxis.X #plane y-axis is (1,0,0) or (-1,0,0)
74 | dp_new = Rhino.Geometry.Point2d(tp.Y*px, p_r.X*py)
75 | e1_new = Rhino.Geometry.Point2d(0, 0)
76 | e2_new = Rhino.Geometry.Point2d(e2.Y*px, e2.X*py)
77 | #perform the move
78 | dim.Geometry.SetLocations(e1_new,e2_new,dp_new)
79 | dim.CommitChanges()
80 | if __name__ == '__main__':
81 | align_dims()
82 |
--------------------------------------------------------------------------------
/layout-tools/annotation_balloon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/layout-tools/annotation_balloon.png
--------------------------------------------------------------------------------
/layout-tools/annotation_balloon.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 | import Rhino
3 | import scriptcontext as sc
4 | import System
5 | from System.Drawing import Color as Col
6 |
7 |
8 |
9 |
10 | def get_block_index(blockname):
11 | #blockcount = sc.doc.ActiveDoc.InstanceDefinitions.ActiveCount
12 | blocks = sc.doc.ActiveDoc.InstanceDefinitions
13 | blocknames=[]
14 | for block in blocks:
15 | if block.Name!= None and not block.Name.__contains__("titleblock"):
16 | if rs.IsBlockInUse(block.Name, where_to_look=sc.sticky['top_level_only']):
17 | blocknames.append(block.Name)
18 | return blocknames.index(blockname)
19 |
20 |
21 | def annotation_balloon():
22 | """
23 | Adds a numbered balloon to the document based on the numbering in part list.
24 | Works only with block items, similar to how this works in 'solid modelers'
25 | on parts in assemblies
26 | www.studiogijs.nl
27 |
28 | version 1.1: option for choosing between all or only top level blocks
29 |
30 | """
31 |
32 | t = sc.sticky['top_level_only'] if sc.sticky.has_key('top_level_only') else False #0 = top level only, 1= all blocks
33 | if t==None:
34 | t=False
35 | top_level_only = rs.GetBoolean("annotate top level blocks only?", ["top_level_only", "yes", "no"],t)
36 | if not top_level_only:
37 | return
38 | sc.sticky['top_level_only'] = top_level_only[0]
39 |
40 | name = get_blockname()
41 | if not name:
42 | return
43 |
44 | previous_layer = rs.CurrentLayer()
45 | #check if layer 'annotation' exist, else create it
46 | if not rs.IsLayer("annotation"): rs.AddLayer("annotation")
47 | rs.LayerColor("annotation",Col.Black)
48 |
49 | rs.CurrentLayer("annotation")
50 |
51 | block_nr = get_block_index(name)+1
52 |
53 | curve, size = get_input()
54 | if curve and size:
55 | aCircle, aText, aCurve = add_annotation_circle(curve, block_nr, size)
56 | aEndDot = add_end_dot(curve, size)
57 | else:
58 | rs.CurrentLayer(previous_layer)
59 | return
60 | #create annotation object
61 | groupname = 'annotation-object_'+str(block_nr)
62 | rs.AddGroup(groupname)
63 | rs.AddObjectsToGroup([aCircle, aText, aCurve, aEndDot], groupname)
64 |
65 | groups = sc.doc.ActiveDoc.Groups
66 | for group in groups:
67 | if group.Name == groupname:
68 | group.SetUserString("group-nr", str(block_nr))
69 | group.SetUserString("block-name", name)
70 | #change back to previous layer
71 | rs.CurrentLayer(previous_layer)
72 |
73 |
74 |
75 | def add_annotation_circle(curve, block_nr, s):
76 | """
77 | adds a circle with text at user specified size to the end of a curve
78 | returns circle and number
79 | """
80 | vector = curve.TangentAtEnd
81 | vector*=s
82 | pt = curve.PointAtEnd
83 | pt+=vector
84 | circle = Rhino.Geometry.Circle(pt, s)
85 | hatchcurve = circle.ToNurbsCurve()
86 | circle = sc.doc.Objects.AddCircle(circle)
87 | curve = sc.doc.Objects.Add(curve)
88 | text = str(block_nr)
89 | plane = Rhino.Geometry.Plane.WorldXY
90 | plane.Origin = pt
91 | just = Rhino.Geometry.TextJustification.MiddleCenter
92 | text = sc.doc.Objects.AddText(text, plane, s*0.6 ,'Courier Std', False, False, just)
93 | return circle, text, curve
94 |
95 | def add_end_dot(curve, s):
96 | """
97 | creates a hatched circle at the start of a curve
98 | """
99 | d = s/5
100 | pt = curve.PointAtStart
101 | circle = Rhino.Geometry.Circle(pt, d)
102 | circle = circle.ToNurbsCurve()
103 | hatch = Rhino.Geometry.Hatch.Create(circle, 0, 0, 0)
104 | dot = sc.doc.Objects.AddHatch(hatch[0])
105 | return dot
106 |
107 |
108 | def get_input():
109 | """
110 | returns the drawn curve, annotation size and value on success, or False on failure
111 | """
112 | s = sc.sticky['annSize'] if sc.sticky.has_key('annSize') else 5 #size of circle radius
113 | if s==None:
114 | s=5
115 | size = rs.GetInteger("size of annotation", s, 3)
116 | sc.sticky['annSize'] = size
117 | curve = get_polyline()
118 |
119 | if curve:
120 | curve = curve.ToNurbsCurve()
121 | return curve, size
122 | return False, False
123 |
124 | def get_polyline():
125 | points = rs.GetPoints(draw_lines = True, in_plane = True, max_points = 3)
126 | if points and len(points)>1:
127 | return Rhino.Geometry.Polyline(points)
128 | return False
129 |
130 | def get_blockname():
131 | """
132 | input: user input selected block
133 | returns block name on succes
134 | """
135 | go = Rhino.Input.Custom.GetObject()
136 | go.SetCommandPrompt("Select block instance to annotate")
137 | go.GeometryFilter = Rhino.DocObjects.ObjectType.InstanceReference
138 | go.EnablePreSelect(False, True)
139 | go.InactiveDetailPickEnabled = True
140 | rc = go.Get()
141 | if rc == Rhino.Input.GetResult.Object:
142 |
143 | objref = go.Object(0)
144 | obj = objref.Object()
145 | name = rs.BlockInstanceName(obj.Id)
146 | return name
147 | return False
148 |
149 | if __name__ == '__main__':
150 | annotation_balloon()
--------------------------------------------------------------------------------
/layout-tools/change_block_description.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 |
3 | def change_block_description():
4 |
5 | """
6 | change or set a block description
7 |
8 | version 1.0
9 | www.studiogijs.nl
10 | """
11 |
12 |
13 | block = rs.GetObject("select block to add or change description", filter = 4096, preselect = True)
14 | if not block:
15 | return
16 | block = rs.coercerhinoobject(block).InstanceDefinition
17 |
18 | desc = rs.BlockDescription(block.Name)
19 | if desc == None:
20 | print ("Current description not set")
21 | else:
22 | print ("Current description: " + desc)
23 | newdesc = rs.GetString("Set new description, to use spaces enter description between \" \"")
24 | if newdesc:
25 | rs.BlockDescription(block.Name, newdesc)
26 |
27 |
28 |
29 | if __name__=="__main__":
30 | change_block_description()
--------------------------------------------------------------------------------
/layout-tools/change_page_scale.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 | def change_page_scale():
5 |
6 | #set focus to page
7 | pageview = sc.doc.Views.ActiveView
8 | pageview.SetPageAsActive()
9 | id = str(pageview.ActiveViewportID)
10 | view_port = pageview.MainViewport
11 | page_scales = ["1:100","1:50","1:20","1:10","1:5","1:2","1:1","2:1","5:1","10:1"]
12 | value = rs.ListBox(page_scales, "Set page scale", "Page scale", "1:5")
13 | if not value:
14 | return
15 | view_port.SetUserString("page_scale",value)
16 | page_scale = Rhino.Runtime.TextFields.LayoutUserText(id, "page_scale")
17 | return page_scale
18 | if __name__ == '__main__':
19 | change_page_scale()
--------------------------------------------------------------------------------
/layout-tools/organize_annotations.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 | from System.Drawing import Color as Col
5 |
6 | def organize_annotations():
7 | """
8 | - puts all dimensions found in all pages on layer 'dim' and annotations on 'annotation'
9 | - creates layer called 'dim' + 'annotation' if it doesn't exist and changes its color to black
10 | version 1.0
11 | www.studiogijs.nl
12 | """
13 |
14 | #check if layer 'dim' exist, else create it
15 | if not rs.IsLayer("dim"): rs.AddLayer("dim")
16 | rs.LayerColor("dim",Col.Black)
17 |
18 | #check if layer 'annotation' exist, else create it
19 | if not rs.IsLayer("annotation"): rs.AddLayer("annotation")
20 | rs.LayerColor("annotation",Col.Black)
21 |
22 | objects = Rhino.RhinoDoc.ActiveDoc.Objects.FindByObjectType(Rhino.DocObjects.ObjectType.Annotation)
23 |
24 | for obj in objects:
25 |
26 | if type(obj)==Rhino.DocObjects.LeaderObject or type(obj)==Rhino.DocObjects.TextObject:
27 | rs.ObjectLayer(obj, "annotation")
28 | else:
29 | rs.ObjectLayer(obj, "dim")
30 |
31 | if __name__ == '__main__':
32 | organize_annotations()
--------------------------------------------------------------------------------
/layout-tools/organize_details.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 | import System.Drawing.Color as Col
5 |
6 | def organize_details():
7 | """
8 | - puts all details on layer 'details'
9 | - creates layer called 'details' if it doesn't exist and changes its color to green
10 | version 1.0
11 | www.studiogijs.nl
12 | """
13 |
14 | #check if layer 'details' exist, else create it
15 | if not rs.IsLayer("details"): rs.AddLayer("details")
16 | rs.LayerColor("details",Col.Aquamarine)
17 | pageviews = sc.doc.Views.GetPageViews()
18 | for pageview in pageviews:
19 | #get all details
20 | details = pageview.GetDetailViews()
21 | for detail in details:
22 | rs.ObjectLayer(details, "details")
23 |
24 | if __name__ == '__main__':
25 | organize_details()
--------------------------------------------------------------------------------
/layout-tools/page_scale_helpers.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 |
5 | def select_scale():
6 |
7 | """
8 | returns selected scale (e.g. 1:5, 1:1, etc.) from list box (predefined scales)
9 | """
10 | pageview = sc.doc.Views.ActiveView
11 | pageview.SetPageAsActive()
12 | page_scale = pageview.ActiveViewport.GetUserString("page_scale")
13 | scales = ["1:100","1:50","1:20","1:10","1:5","1:2","1:1","2:1","5:1","10:1"]
14 | if (page_scale==None) or (page_scale not in scales):
15 | value = rs.ListBox(scales, "Select scale", "Scale", "1:5")
16 | else:
17 | value = rs.ListBox(scales, "Select scale", "Scale", page_scale)
18 | if not value:
19 | return False
20 | else:
21 | return value
22 |
23 | def change_page_scale():
24 |
25 | """
26 | returns the selected page scale (e.g. 1:5, 1:1 etc.) or none if canceled
27 | """
28 |
29 | #set focus to page
30 | pageview = sc.doc.Views.ActiveView
31 | pageview.SetPageAsActive()
32 | id = str(pageview.ActiveViewportID)
33 | view_port = pageview.MainViewport
34 | value = select_scale()
35 | if not value:
36 | return
37 | view_port.SetUserString("page_scale",value)
38 | page_scale = pageview.ActiveViewport.GetUserString("page_scale")
39 | return page_scale
40 |
41 |
42 | def get_scale(readable_scale):
43 |
44 | """
45 | input values:
46 | readable_scale
47 | returns readable_scale to scale (e.g. 1:50 --> 0.02)
48 | """
49 |
50 | scale = None
51 | if readable_scale =="1:100": scale = 0.01
52 | if readable_scale =="1:50": scale = 0.02
53 | if readable_scale =="1:20": scale = 0.05
54 | if readable_scale =="1:10": scale = 0.1
55 | if readable_scale =="1:5": scale = 0.2
56 | if readable_scale =="1:2": scale = .5
57 | if readable_scale =="1:1": scale = 1.0
58 | if readable_scale =="2:1": scale = 2.0
59 | if readable_scale =="5:1": scale = 5.0
60 | if readable_scale =="10:1": scale = 10.0
61 | #leave any other readable ratio that doesn't fit the bill
62 | if not scale:
63 | return False
64 | else:
65 | return scale
66 |
67 | def set_detail_scale(detail, scale):
68 | """
69 | input values:
70 | detail (DetailViewObject, the detail to change)
71 | scale (float, the scale to set the detail to)
72 | changes detail's scale
73 | returns True on succes
74 | """
75 |
76 | #modify the scale
77 | pageview = sc.doc.Views.ActiveView
78 | pageview.SetActiveDetail(detail.Id)
79 | if scale<=1.0:
80 | readable_scale = "1:" + str(int(1/scale))
81 | else:
82 | readable_scale = str(int(scale)) + ":1"
83 | attribs = detail.Attributes.Duplicate()
84 | attribs.SetUserString("detail_scale", readable_scale)
85 | sc.doc.Objects.ModifyAttributes(detail.Id, attribs, True)
86 |
87 | detail.DetailGeometry.SetScale(1, sc.doc.ModelUnitSystem, scale, sc.doc.PageUnitSystem)
88 | #lock detail
89 | detail.DetailGeometry.IsProjectionLocked = True
90 | detail.CommitChanges()
91 |
92 | #set focus back to page
93 | pageview.SetPageAsActive()
94 | sc.doc.Views.Redraw()
95 | return True
96 |
--------------------------------------------------------------------------------
/layout-tools/projected_view.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import scriptcontext as sc
3 | import rhinoscriptsyntax as rs
4 | from System.Drawing import Color
5 | from Rhino.Geometry import Point3d, Vector3d, Plane, Transform, Rectangle3d
6 | from math import pi as pi
7 |
8 |
9 |
10 | def create_projected_detail():
11 | """
12 | This script will create a projected view from a selected detail
13 | front/back from top view
14 | left/right from front view
15 | back from right or left view
16 |
17 | version 0.7
18 |
19 | new in 0.2:
20 | - locked details should now work better
21 | new in 0.3:
22 | - projected views now have their cplane set to the view, which should result in better behavior when editing the detail
23 | - projected views from top or bottom views to right or left are ignored with user message.
24 | - message when trying to add projected view from perspective
25 | new in 0.4:
26 | - new details now have their title correctly set to the actual view projection
27 | new in 0.5:
28 | - new detail preview now snaps to the selected detail, to make it more clear where it ends
29 | - temporarily disable osnaps during operation
30 | new in 0.6:
31 | - fixed a bug that prevented the projection to be altered when the selected detail was locked
32 | new in 0.7
33 | -cleaned up code, bug fixes
34 |
35 | www.studiogijs.nl
36 | """
37 | def restore_osnap():
38 | #restore osnapmode
39 | Rhino.ApplicationSettings.ModelAidSettings.Osnap = osnap
40 |
41 | def rotate_viewport(vect):
42 | angle = pi/2
43 | if Rhino.ApplicationSettings.ViewSettings.RotateReverseKeyboard: angle = -angle
44 | if abs(vect.X)>abs(vect.Y): #make horizontal view
45 | if VP==1 or VP==4:
46 | print ("Can't make a correct projection of this view on left or right")
47 | rs.DeleteObject(newdetail)
48 | restore_osnap()
49 | return
50 | pass
51 | if VP==2 or VP==6:
52 | newplane = Rhino.Geometry.Plane(Rhino.Geometry.Point3d.Origin, Rhino.Geometry.Plane.WorldXY.XAxis)
53 | view.ActiveViewport.SetConstructionPlane(newplane)
54 | if viewportname == "front":
55 | if vect.X<0:
56 | #left view from front
57 | new_viewport_name = "Left"
58 | else:
59 | new_viewport_name = "Right"
60 |
61 | if viewportname == "back":
62 | if vect.X<0:
63 | #left view from back
64 | new_viewport_name = "Right"
65 | else:
66 | new_viewport_name = "Left"
67 |
68 | elif VP==3 or VP==5:
69 | newplane = Rhino.Geometry.Plane(Rhino.Geometry.Point3d.Origin, Rhino.Geometry.Plane.WorldXY.YAxis)
70 | view.ActiveViewport.SetConstructionPlane(newplane)
71 | if viewportname == "left":
72 | if vect.X<0:
73 | #left view from left
74 | new_viewport_name = "Back"
75 | else:
76 | new_viewport_name = "Front"
77 | if viewportname == "right":
78 | if vect.X<0:
79 | #left view from right
80 | new_viewport_name = "Front"
81 | else:
82 | new_viewport_name = "Back"
83 |
84 | if vect.X<0:
85 | view.ActiveViewport.KeyboardRotate(True,angle)#rotate left
86 | else:
87 | view.ActiveViewport.KeyboardRotate(True,-angle)#rotate right
88 |
89 | else:
90 | if VP==1 or VP==4:
91 | newplane = Rhino.Geometry.Plane(Rhino.Geometry.Point3d.Origin, Rhino.Geometry.Plane.WorldXY.YAxis)
92 | view.ActiveViewport.SetConstructionPlane(newplane)
93 | if viewportname == "top":
94 | if vect.Y<0:
95 | #front view from top
96 | new_viewport_name = "Front"
97 | else:
98 | new_viewport_name = "Back"
99 | if viewportname == "bottom":
100 | if vect.Y<0:
101 | #back view from bottom
102 | new_viewport_name = "Back"
103 | else:
104 | new_viewport_name = "Front"
105 | elif VP==2 or VP==3 or VP==5 or VP==6:
106 | newplane = Rhino.Geometry.Plane(Rhino.Geometry.Point3d.Origin, Rhino.Geometry.Plane.WorldXY.ZAxis)
107 | view.ActiveViewport.SetConstructionPlane(newplane)
108 | if vect.Y<0:
109 | #bottom view from front, right, left or back
110 | new_viewport_name = "Bottom"
111 | else:
112 | new_viewport_name = "Top"
113 | if vect.Y<0:
114 | view.ActiveViewport.KeyboardRotate(False,angle)#rotate down
115 | else:#Y>0
116 | view.ActiveViewport.KeyboardRotate(False,-angle)#rotate up
117 | return new_viewport_name
118 |
119 | def OnDynamicDraw(sender, e):
120 |
121 |
122 | rot=""
123 | plane = Plane(ptLL, Plane.WorldXY.ZAxis)
124 | sizeX = ptLR.X-ptLL.X #width of selected detail
125 | sizeY = ptUR.Y-ptLR.Y #height of selected detail
126 | vec = e.CurrentPoint-basept
127 | if abs(vec.X)>abs(vec.Y):
128 | if vec.X>0:
129 | translate = Vector3d(sizeX,0,0)
130 | if rot!="right":
131 | rot="right"
132 | else:
133 | translate = Vector3d(-sizeX,0,0)
134 | if rot!="left":
135 | rot="left"
136 | elif abs(vec.Y)>abs(vec.X):
137 | if vec.Y>0:
138 | translate = Vector3d(0,sizeY,0,)
139 | if rot!="up":
140 | rot="up"
141 | else:
142 | translate = Vector3d(0,-sizeY,0)
143 | if rot!="down":
144 | rot="down"
145 |
146 | else:
147 | translate = vec
148 | xf = Transform.Translation(translate)
149 | newobj = Rectangle3d(plane,sizeX,sizeY)
150 | crv = newobj.ToNurbsCurve()
151 | preview=crv.Duplicate()
152 | preview.Transform(xf)
153 | e.Display.DrawCurve(preview, Color.LightCyan, 2)
154 |
155 |
156 | def get_point():
157 | while True:
158 | result = gp.Get()
159 | if result == Rhino.Input.GetResult.Point:
160 | #count=optInt.CurrentValue
161 | line = Rhino.Geometry.Line(basept, gp.Point())
162 | return line
163 | break
164 |
165 | #set focus page and select detail
166 | pageview = sc.doc.Views.ActiveView
167 | pageview.SetPageAsActive()
168 | filter = Rhino.DocObjects.ObjectType.Detail
169 | rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select detail to create projected drawing of", False, filter)
170 | if not objref or rc != Rhino.Commands.Result.Success:
171 | return
172 | detail_obj = objref.Object()
173 | if not isinstance(detail_obj, Rhino.DocObjects.DetailViewObject):
174 | return
175 |
176 | #get lower left and lower right and upper right points of selected detail view
177 | ptLL = Point3d(0,0,0)
178 | ptLR = Point3d(0,0,0)
179 | ptUR = Point3d(0,0,0)
180 | ptLL = detail_obj.Geometry.GetBoundingBox(Plane.WorldXY).Min
181 | ptLR.X = detail_obj.Geometry.GetBoundingBox(Plane.WorldXY).Max.X
182 | ptLR.Y = detail_obj.Geometry.GetBoundingBox(Plane.WorldXY).Min.Y
183 | ptUR = detail_obj.Geometry.GetBoundingBox(Plane.WorldXY).Max
184 | basept = (ptLL + ptUR)/2 #center of Detail view
185 |
186 | gp=Rhino.Input.Custom.GetPoint()
187 | gp.SetCommandPrompt("where to add projected view")
188 | gp.DynamicDraw += OnDynamicDraw
189 |
190 | #temporarily disable osnaps if enabled
191 | osnap = Rhino.ApplicationSettings.ModelAidSettings.Osnap
192 | Rhino.ApplicationSettings.ModelAidSettings.Osnap = False
193 | line = get_point()
194 | if not line:
195 | restore_osnap()
196 | return
197 | vect = line.To - basept
198 |
199 | #determine which side the new detail should go
200 | if abs(vect.X)>abs(vect.Y): #add view to left or right of selected detail
201 | if vect.X<0: #add view left
202 | translation = rs.VectorSubtract(ptLL, ptLR) # to the left
203 | else:
204 | translation = rs.VectorSubtract(ptLR, ptLL) # to the right
205 | else: #add view on top or bottom of selected detail
206 | if vect.Y<0: #add view down
207 | translation = rs.VectorSubtract(ptLR, ptUR) # down
208 | else:
209 | translation = rs.VectorSubtract(ptUR, ptLR) # up
210 |
211 | #create new detail
212 | rs.EnableRedraw = False
213 | newdetail = rs.CopyObject(detail_obj, translation)
214 | d = rs.coercerhinoobject(newdetail)
215 | lockedstate = d.DetailGeometry.IsProjectionLocked
216 | d.DetailGeometry.IsProjectionLocked = False
217 | d.CommitViewportChanges()
218 | d.CommitChanges()
219 |
220 | #set new detail as active detail
221 | view = sc.doc.Views.ActiveView
222 | view.SetActiveDetail(newdetail)
223 |
224 | #determine what the current viewport projection is
225 | VP = 0
226 | new_viewport_name = ""
227 | if d.Viewport.CameraZ==Rhino.Geometry.Vector3d(0,0,1):
228 | #top view
229 | viewportname = "top"
230 | VP=1
231 | elif d.Viewport.CameraZ==Rhino.Geometry.Vector3d(0,-1,0):
232 | #front view
233 | viewportname = "front"
234 | VP=2
235 | elif d.Viewport.CameraZ==Rhino.Geometry.Vector3d(1,0,0):
236 | #right view
237 | viewportname = "right"
238 | VP=3
239 | elif d.Viewport.CameraZ==Rhino.Geometry.Vector3d(0,0,-1):
240 | #bottom view
241 | viewportname = "bottom"
242 | VP=4
243 | elif d.Viewport.CameraZ==Rhino.Geometry.Vector3d(-1,0,0):
244 | #left view
245 | viewportname = "left"
246 | VP=5
247 | elif d.Viewport.CameraZ==Rhino.Geometry.Vector3d(0,1,0):
248 | #back view
249 | viewportname = "back"
250 | VP=6
251 | else:
252 | restore_osnap()
253 | return
254 |
255 | #make the rotation to the viewport
256 | new_view_name = rotate_viewport(vect)
257 | viewport = d.Viewport
258 | title = viewport.Name
259 | print (viewport.Name)
260 | viewport.Name = new_view_name
261 |
262 | d.DetailGeometry.IsProjectionLocked = lockedstate
263 | print (d.CommitViewportChanges())
264 | #d.CommitChanges()
265 | sc.doc.Views.ActiveView.SetPageAsActive()
266 | restore_osnap()
267 | sc.doc.Views.Redraw()
268 | rs.EnableRedraw = True
269 | if __name__=="__main__":
270 | create_projected_detail()
271 |
--------------------------------------------------------------------------------
/layout-tools/set_detail_scale.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 | import page_scale_helpers as psh
5 |
6 | def main():
7 | """
8 | - sets a predefined scale from a list for selected detail(s), defaults to page scale
9 |
10 | version 0.2
11 | www.studiogijs.nl
12 | """
13 | pageview = sc.doc.Views.ActiveView
14 | if type(pageview) != Rhino.Display.RhinoPageView:
15 | print ("This tool only works in layout space.")
16 | return
17 | details = rs.GetObjects("select detail(s) to change scale",32768, preselect=True)
18 | if not details:
19 | return
20 | value = psh.select_scale()
21 | if not value:
22 | return
23 | scale = psh.get_scale(value)
24 | for detail in details:
25 |
26 | detail = rs.coercerhinoobject(detail)
27 | if not detail.DetailGeometry.IsParallelProjection:
28 | continue
29 | psh.set_detail_scale(detail, scale)
30 |
31 |
32 |
33 | if __name__ == '__main__':
34 | main()
35 |
--------------------------------------------------------------------------------
/layout-tools/set_details_scale_to_page_scale.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 | import page_scale_helpers as psh
5 |
6 |
7 |
8 | def set_details_scale_to_page_scale():
9 | """
10 | This script changes the scale of the details to the page scale and adds a page scale if not set
11 |
12 | version 0.1
13 | www.studiogijs.nl
14 | """
15 |
16 | #set focus to page
17 | pageview = sc.doc.Views.ActiveView
18 | pageview.SetPageAsActive()
19 | id = str(pageview.ActiveViewportID)
20 | #set page scale
21 | page_scale = psh.change_page_scale()
22 | scale = psh.get_scale(page_scale)
23 | if not scale:
24 | return
25 | #get all details on page, set scale to page scale
26 | details = pageview.GetDetailViews()
27 | for detail in details:
28 | psh.set_detail_scale(detail, scale)
29 |
30 | sc.doc.Views.Redraw()
31 |
32 | if __name__ == '__main__':
33 | set_details_scale_to_page_scale()
--------------------------------------------------------------------------------
/layout-tools/set_page_and_details_scale.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 | import page_scale_helpers as psh
5 |
6 | def main():
7 | """
8 | Sets page scale and changes all details to the same scale. Adds 'page_scale'
9 | user text key and value to the page and detail_scale user text to details
10 | """
11 |
12 | pageview = sc.doc.Views.ActiveView
13 | if type(pageview) != Rhino.Display.RhinoPageView:
14 | print ("This tool only works in layout space.")
15 | return
16 | pagescale = psh.change_page_scale()#returns readable scale e.g. 1:5, 2:1
17 |
18 | if not pagescale:
19 | return
20 | scale = psh.get_scale(pagescale)#returns page scale ratio e.g 0.2, 2.0
21 | print (scale)
22 | details = pageview.GetDetailViews()
23 | if not details:
24 | return
25 | for detail in details:
26 | if not detail.DetailGeometry.IsParallelProjection:
27 | continue
28 | psh.set_detail_scale(detail, scale)
29 |
30 | if __name__=="__main__":
31 | main()
32 |
--------------------------------------------------------------------------------
/layout-tools/set_page_scale.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 | import page_scale_helpers as psh
5 |
6 | def main():
7 | """
8 | - Sets page scale by adding 'page_scale' user text key and value
9 | version 1.0
10 | www.studiogijs.nl
11 | """
12 |
13 | pageview = sc.doc.Views.ActiveView
14 | if type(pageview) != Rhino.Display.RhinoPageView:
15 | print ("This tool only works in layout space.")
16 | return
17 | psh.change_page_scale()
18 |
19 | if __name__=="__main__":
20 | main()
21 |
--------------------------------------------------------------------------------
/linestyles/arrowCurve.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 | import scriptcontext as sc
3 |
4 | def arrowCurve():
5 | """
6 | ---->---->---->---->---->---->---->----
7 | this script divides a curve by length and adds dashes to either side of the curve, grouped per curve / polyline
8 | limitation: does not accomodate at corners (to avoid ccx issues)
9 | www.studiogijs.nl
10 | """
11 | curves = rs.GetObjects("select curves to change into arrow-style",4, preselect=True)
12 | if not curves:
13 | return
14 | s=sc.sticky['scale'] if sc.sticky.has_key('scale') else 20
15 | scale = rs.GetReal("scale of the arrow curve", s, 5, 100)
16 |
17 |
18 | if not scale:
19 | return
20 | sc.sticky['scale']=scale
21 |
22 | rs.EnableRedraw(False)
23 |
24 | for curve in curves:
25 | lines=[]
26 | if rs.CurveLength(curve)>scale:
27 | pts = rs.DivideCurveLength(curve, scale)
28 | for pt in pts:
29 | t=rs.CurveClosestPoint(curve, pt)
30 | vec = rs.CurveTangent(curve, t)*scale/10
31 | line = rs.AddLine(pt, pt+vec)
32 | line_copy = rs.CopyObject(line, [0,0,0])
33 | rs.RotateObject(line, pt, 45)
34 | rs.RotateObject(line_copy, pt, -45)
35 | lines.append(line)
36 | lines.append(line_copy)
37 | group = rs.AddGroup()
38 | rs.AddObjectsToGroup(lines, group)
39 | rs.AddObjectsToGroup(curve, group)
40 | rs.SelectObjects(lines)
41 | rs.SelectObjects(curves)
42 | rs.EnableRedraw(True)
43 | arrowCurve()
--------------------------------------------------------------------------------
/linestyles/arrowCurve_fenceCurve_multiLineCurve.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/linestyles/arrowCurve_fenceCurve_multiLineCurve.png
--------------------------------------------------------------------------------
/linestyles/fenceCurve.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/linestyles/fenceCurve.png
--------------------------------------------------------------------------------
/linestyles/fenceCurve.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 | import scriptcontext as sc
3 | def fenceCurve():
4 | """
5 | ---x---x---x---x---x---x---
6 | this script divides a curve by length and adds 'crosses' to it, grouped per curve / polyline
7 | www.studiogijs.nl
8 | """
9 | curves = rs.GetObjects("select curves to change into fence-style",4, preselect=True)
10 | if not curves:
11 | return
12 |
13 |
14 | s=sc.sticky['scale'] if sc.sticky.has_key('scale') else 20
15 | scale = rs.GetReal("scale of the arrow curve", s, 5, 100)
16 |
17 |
18 | if not scale:
19 | return
20 | sc.sticky['scale']=scale
21 |
22 |
23 | rs.EnableRedraw(False)
24 |
25 | for curve in curves:
26 | lines=[]
27 | if rs.CurveLength(curve)>scale:
28 | pts = rs.DivideCurveLength(curve, scale)
29 | for pt in pts:
30 | t=rs.CurveClosestPoint(curve, pt)
31 | vec = rs.CurveTangent(curve, t)
32 | line = rs.AddLine(pt-vec*scale/10, pt+vec*scale/10)
33 | rs.RotateObject(line, pt, 45)
34 | lines.append(line)
35 | line_copy = rs.RotateObject(line, pt, 90, copy=True)
36 | lines.append(line_copy)
37 | group = rs.AddGroup()
38 | rs.AddObjectsToGroup(lines, group)
39 | rs.AddObjectsToGroup(curve, group)
40 | rs.SelectObjects(lines)
41 | rs.SelectObjects(curves)
42 | rs.EnableRedraw(True)
43 |
44 | fenceCurve()
--------------------------------------------------------------------------------
/linestyles/hatchedCurve.py:
--------------------------------------------------------------------------------
1 | from __future__ import division
2 | import rhinoscriptsyntax as rs
3 | import scriptcontext as sc
4 | import Rhino
5 | #from System.Drawing import Color
6 |
7 | def hatchedCurve():
8 | """
9 | this script divides a curve by length and makes a hatch-dashed version of it'
10 | works only in world top
11 | version 1.1
12 | www.studiogijs.nl
13 | """
14 |
15 | projection = Rhino.Geometry.Vector3d(0,0,1)
16 | viewprojection = sc.doc.Views.ActiveView.ActiveViewport.CameraZ
17 | if not viewprojection == projection:
18 | print " this script only works in top view"
19 | return
20 | getcurves = rs.GetObjects("select curves to change into hatch-dashed-style",4, preselect=True)
21 | rs.UnselectAllObjects()
22 | if not getcurves:
23 | return
24 |
25 | s=sc.sticky['scale'] if sc.sticky.has_key('scale') else 1
26 | scale = rs.GetReal("line-width of the hatch-dashed curve", s, .5, 5)
27 |
28 | if not scale:
29 | return
30 | sc.sticky['scale']=scale
31 |
32 | f=sc.sticky['factor'] if sc.sticky.has_key('factor') else 5
33 | factor = rs.GetReal("line-length factor of the hatch-dashed curve", f, 1, 10)
34 |
35 | if not factor:
36 | return
37 | sc.sticky['factor']=factor
38 |
39 | #turn of the lights, magic should be done in darkness
40 | rs.EnableRedraw(False)
41 |
42 | style = Rhino.Geometry.CurveOffsetCornerStyle.Sharp
43 | tol = sc.doc.ModelAbsoluteTolerance
44 | plane = Rhino.Geometry.Plane.WorldXY
45 |
46 | subcurvelist=[]
47 | offset_curves=[]
48 | for curve in getcurves:
49 | # ------------------------------------------------------
50 | # offset curves inward and outward to create the borders
51 | # ------------------------------------------------------
52 | c = rs.coercecurve(curve)
53 | if not rs.IsCurvePlanar(curve):
54 | continue
55 | #else:
56 | #rs.HideObject(curve)
57 |
58 | offsets =c.Offset(plane, scale/2, tol, style)
59 | if offsets:
60 | offset = sc.doc.Objects.Add(offsets[0])
61 | offset_curves.append(offset)
62 | offsets =c.Offset(plane, -scale/2, tol, style)
63 | if offsets:
64 | offset = sc.doc.Objects.Add(offsets[0])
65 | offset_curves.append(offset)
66 | # -----------------------------------
67 | # explode c into segments if possible
68 | # -----------------------------------
69 | exploded = rs.ExplodeCurves(c)
70 | if exploded :
71 | for segment in exploded:
72 | subcurvelist.append(segment)
73 | else:
74 | #it appears this is for single lines only
75 | subcurvelist.append(rs.CopyObject(curve))
76 |
77 | segments=[]
78 | # -------------------------------------------------------
79 | # divide subcurves into shorter segments (dashed pattern)
80 | # -------------------------------------------------------
81 | for curve in subcurvelist:
82 | closed=False
83 | if rs.coercecurve(curve).IsClosed:
84 | closed=True
85 | if rs.CurveLength(curve)>(scale*factor):
86 | segment_count = int(rs.CurveLength(curve)/(scale*factor/2))
87 | while True:
88 | #we need to start with 1/2 segment, then full space, then half segment
89 | #so #of segments needs to be a multiple of 4
90 | if segment_count%4==0: break
91 | else: segment_count+=1
92 |
93 | pts = rs.DivideCurve(curve, segment_count)
94 |
95 | if closed:
96 | pts = pts[1:] #remove only first point, since last point == first
97 | pts = pts[1:-1] #remove first and last point
98 |
99 | pts = pts[::2] #remove every other point
100 | # --------------
101 | # dash the curve
102 | # --------------
103 | for i, pt in enumerate(pts):
104 | t = rs.CurveClosestPoint(curve, pt)
105 | curves = rs.SplitCurve(curve, t)
106 | curve = curves[1]
107 | segment = curves[0]
108 | if closed:
109 | #delete every odd segment
110 | if i%2==0:
111 | rs.DeleteObject(segment)
112 | else: segments.append(segment)
113 | else:
114 | #delete every even segment
115 | if i%2==1:
116 | rs.DeleteObject(segment)
117 | else:
118 | segments.append(segment)
119 |
120 | #append the remaining part
121 | segments.append(curve)
122 |
123 | def hatchthis(s):
124 |
125 | #offset all segments
126 | s=rs.coercecurve(s)
127 | offsets = s.Offset(plane, scale/2, tol, style)
128 | if offsets:
129 | p1,p2, curve1 = getPointsAndLines(offsets)
130 | offsets = s.Offset(plane, -scale/2, tol, style)
131 | if offsets:
132 | p3,p4, curve2 = getPointsAndLines(offsets)
133 | if not (p1 and p2 and p3 and p4):
134 | return
135 |
136 | #create end lines between the two offset curves
137 | line1 = rs.AddLine(p1, p3)
138 | line2 = rs.AddLine(p2, p4)
139 | polyline = rs.JoinCurves([line1, line2, curve1, curve2], True, tol)
140 |
141 | # FINALLY: hatch the bloody thing
142 | hatch = rs.AddHatch(polyline, 'Solid')
143 |
144 | #clean up
145 | rs.DeleteObject(polyline)
146 |
147 | return hatch
148 |
149 | if segments:
150 | segments = rs.JoinCurves(segments, True)
151 | layer = "hatched_curves"
152 | if not rs.IsLayer(layer):
153 | rs.AddLayer(layer)
154 |
155 | hatches =[]
156 | #create the hatches
157 | for s in segments:
158 | rs.ObjectLayer(hatchthis(s), layer)
159 | for offset in offset_curves:
160 | rs.ObjectLayer(offset, layer)
161 |
162 | #clean up
163 | rs.DeleteObjects(segments)
164 | rs.HideObjects(getcurves)
165 | rs.DeleteObjects(curves)
166 | #put on the lights, it's the result that counts
167 | rs.EnableRedraw(True)
168 |
169 | def getPointsAndLines(offsets):
170 | """
171 | function to get the end points and underlying curve geometry of the offsets
172 | """
173 | if type(offsets[0])==Rhino.Geometry.PolylineCurve:
174 | curve = sc.doc.Objects.AddPolyline(offsets[0].ToPolyline())
175 | c1 = offsets[0].ToPolyline()
176 | p1 = c1.First
177 | p2 = c1.Last
178 | elif type(offsets[0])==Rhino.Geometry.LineCurve:
179 | curve = sc.doc.Objects.AddLine(offsets[0].Line)
180 | c1 = offsets[0].Line
181 | p1 = c1.From
182 | p2 = c1.To
183 | else:
184 | curve = offsets[0]
185 | p1 = curve.PointAtStart
186 | p2 = curve.PointAtEnd
187 | curve = sc.doc.Objects.AddCurve(curve)
188 | return p1, p2, curve
189 |
190 |
191 | if __name__ == "__main__":
192 | hatchedCurve()
193 |
--------------------------------------------------------------------------------
/linestyles/linetypes.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/linestyles/linetypes.gh
--------------------------------------------------------------------------------
/linestyles/linetypes.gh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/linestyles/linetypes.gh.png
--------------------------------------------------------------------------------
/linestyles/multiLineCurve.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 | import scriptcontext as sc
3 |
4 | def multiLineCurve():
5 | """
6 | --- --- --- --- --- --- --- --- --- --- ---
7 | -------------------------------------------
8 | --- --- --- --- --- --- --- --- --- --- ---
9 | this script divides a curve by length and adds dashes to either side of the curve, grouped per curve / polyline
10 | limitation: does not accomodate at corners (to avoid ccx issues)
11 | www.studiogijs.nl
12 | """
13 | curves = rs.GetObjects("select curves to change into multiline-style",4, preselect=True)
14 | if not curves:
15 | return
16 | s=sc.sticky['scale'] if sc.sticky.has_key('scale') else 20
17 | scale = rs.GetReal("scale of the multiline curve", s, 5, 100)
18 |
19 |
20 | if not scale:
21 | return
22 | sc.sticky['scale']=scale
23 |
24 | rs.EnableRedraw(False)
25 |
26 | for curve in curves:
27 | lines=[]
28 | if rs.CurveLength(curve)>scale:
29 | pts = rs.DivideCurveLength(curve, scale)
30 | for pt in pts:
31 | t=rs.CurveClosestPoint(curve, pt)
32 | vec = rs.CurveTangent(curve, t)*scale/5
33 | line = rs.AddLine(pt-vec, pt+vec)
34 | trans = rs.VectorRotate(vec, 90, [0,0,1])
35 | trans/=2
36 | line_copy = rs.CopyObject(line, trans)
37 | trans = -trans
38 | lines.append(line_copy)
39 | rs.MoveObject(line, trans)
40 | lines.append(line)
41 | group = rs.AddGroup()
42 | rs.AddObjectsToGroup(lines, group)
43 | rs.AddObjectsToGroup(curve, group)
44 | rs.SelectObjects(lines)
45 | rs.SelectObjects(curves)
46 | rs.EnableRedraw(True)
47 |
48 | multiLineCurve()
--------------------------------------------------------------------------------
/linestyles/temp:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/set_gumball.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/set_gumball.png
--------------------------------------------------------------------------------
/set_gumball_max.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | def set_gumball_max():
4 | objs = rs.GetObjects("select objects", preselect=True, select=True)
5 | if not objs:
6 | return
7 | bb = rs.BoundingBox(objs)
8 | origin = bb[6]
9 | command = "GumballRelocate %f,%f,%f Enter" % (origin[0], origin[1], origin[2])
10 | rs.Command(command)
11 | command = "GumballRelocate SetScaleHandles %f %f %f Enter" % (bb[1][0]-bb[0][0], bb[3][1]-bb[0][1], bb[4][2]-bb[0][2])
12 | rs.Command(command)
13 | set_gumball_max()
--------------------------------------------------------------------------------
/set_gumball_min.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | def set_gumball_min():
4 | objs = rs.GetObjects("select objects", preselect=True, select=True)
5 | if not objs:
6 | return
7 | bb = rs.BoundingBox(objs)
8 | origin = bb[0]
9 | command = "GumballRelocate %f,%f,%f Enter" % (origin[0], origin[1], origin[2])
10 | rs.Command(command)
11 | command = "GumballRelocate SetScaleHandles %f %f %f Enter" % (bb[0][0]-bb[1][0], bb[0][1]-bb[3][1], bb[0][2]-bb[4][2])
12 | rs.Command(command)
13 | set_gumball_min()
--------------------------------------------------------------------------------
/thin_sheet_metal/add_cutters_for_rivets.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 | import Rhino
3 | import scriptcontext as sc
4 |
5 | def add_cutters_for_rivets():
6 |
7 | """
8 | This script adds cylinder objects (as a group named 'rivet-hole-cutters')
9 | at rivet block positions to easily cut holes into
10 | the sheet metal objects.
11 |
12 | www.studiogijs.nl
13 | """
14 | depth = 12
15 | origin = Rhino.Geometry.Point3d(0.0,0.0,-depth/2)
16 | direction = Rhino.Geometry.Vector3d(0.0, 0.0, 1.0)
17 | plane = Rhino.Geometry.Plane(origin, direction)
18 |
19 |
20 | blocks = sc.doc.ActiveDoc.InstanceDefinitions
21 |
22 | blocknames=[]
23 |
24 | for block in blocks:
25 | if block.Name!= None:
26 | if block.Name.__contains__("rivet"):
27 | blocknames.append(block.Name)
28 | if len(blocknames)==0:
29 | print "no rivet block items found in this document"
30 | return
31 | rivets = []
32 | for name in blocknames:
33 | instances = rs.BlockInstances(name, 0)
34 | for instance in instances:
35 | rivets.append(instance)
36 | cutters = []
37 | cutter_group = rs.AddGroup("rivet-hole-cutters")
38 | for rivet in rivets:
39 | radius = float(rs.coercerhinoobject(rivet).InstanceDefinition.Name[-5])/2+0.15
40 | circle = Rhino.Geometry.Circle(plane, radius).ToNurbsCurve()
41 | cyl = Rhino.Geometry.Extrusion.Create(circle, depth, True)
42 | xform = rs.BlockInstanceXform(rivet)
43 | trans = Rhino.Geometry.Transform(xform)
44 | cyl.Transform(trans)
45 | cutter = sc.doc.Objects.AddExtrusion(cyl)
46 | rs.AddObjectToGroup(cutter, "rivet-hole-cutters")
47 |
48 | sc.doc.Views.Redraw()
49 |
50 | if __name__== "__main__":
51 | add_cutters_for_rivets()
--------------------------------------------------------------------------------
/thin_sheet_metal/add_rivets.py:
--------------------------------------------------------------------------------
1 | from __future__ import division
2 | import rhinoscriptsyntax as rs
3 | from Rhino.ApplicationSettings import *
4 | import Rhino
5 | import math
6 | import scriptcontext as sc
7 | from System.Drawing import Color
8 | import Rhino.RhinoMath as rm
9 |
10 |
11 | """
12 | add_rivets version 1.0
13 |
14 | this script will add a rivet (named block) in Metric size to the rhino document
15 | The rivet must be oriented on a surface and can be aligned with a center point or point
16 | needed user input : rivet diameter, length, (center)point on (poly)surface
17 |
18 | use add_cutters_for_rivets.py to insert cutters at rivet positions
19 |
20 | -based on addBolt v0.8 script
21 |
22 | script written by Gijs de Zwart
23 | www.studiogijs.nl
24 |
25 | """
26 |
27 | class Rivet():
28 | def __init__(self, size, length):
29 | diameter = {'3mm':3.0, '4mm':4.0, '5mm':5.0}
30 | self.diameter = diameter[size]
31 | self.length = length
32 | self.name = "rivet_D"+size+"x"+str(length)
33 | self.breps = []
34 | self.curves = []
35 | self.size = size
36 | def __repr__(self):
37 | cls = self.__class__.__name__
38 | return '{}({}x{})'.format(cls, self.size, self.length)
39 | def __str__(self):
40 | return self.name
41 |
42 | class Countersunk(Rivet):
43 | def __init__(self, size, length):
44 | Rivet.__init__(self, size, length)
45 | self.name ="countersunk_"+self.name
46 |
47 | class Blind(Rivet):
48 | def __init__(self, size, length):
49 | Rivet.__init__(self, size, length)
50 | self.name ="blind_"+self.name
51 |
52 | def get_rivet_properties():
53 |
54 |
55 | #collect previous settings
56 | r_size = sc.sticky["r_size"] if sc.sticky.has_key("r_size") else 0
57 | r_length= sc.sticky["r_length"] if sc.sticky.has_key("r_length") else 0
58 | r_type= sc.sticky["r_type"] if sc.sticky.has_key("r_type") else 1
59 |
60 |
61 | get_o = Rhino.Input.Custom.GetOption()
62 | get_o.SetCommandPrompt("Set Rivet Parameters")
63 |
64 | r_sizes = ['3mm','4mm', '5mm']
65 | r_size_index = get_o.AddOptionList("Rivet_Diameter", r_sizes, r_size)
66 |
67 | r_lengths=['2mm','3mm','4mm','5mm','6mm']
68 | r_length_index = get_o.AddOptionList("Rivet_Length", r_lengths, r_length)
69 |
70 | r_types=['countersunk','blind']
71 | r_type_index = get_o.AddOptionList("Rivet_Type", r_types, r_type)
72 |
73 | #accept Enter as an option
74 | get_o.AcceptNothing(True)
75 |
76 | while True:
77 | # perform the get operation. This will prompt the user to
78 | # input a point, but also allow for command line options
79 | # defined above
80 | get_rc = get_o.Get()
81 | if get_o.CommandResult()!= Rhino.Commands.Result.Success:
82 | return None,None,None
83 |
84 | if get_rc==Rhino.Input.GetResult.Nothing:
85 | pass
86 |
87 |
88 |
89 | elif get_rc==Rhino.Input.GetResult.Option:
90 |
91 | if get_o.OptionIndex() == r_size_index:
92 | r_size = get_o.Option().CurrentListOptionIndex
93 |
94 | if get_o.OptionIndex() == r_length_index:
95 | r_length = get_o.Option().CurrentListOptionIndex
96 |
97 | if get_o.OptionIndex() == r_type_index:
98 | r_type = get_o.Option().CurrentListOptionIndex
99 |
100 | continue
101 |
102 | break
103 |
104 |
105 | sc.sticky["r_size"] = r_size
106 | sc.sticky["r_length"] = r_length
107 | sc.sticky["r_type"] = r_type
108 |
109 |
110 |
111 | size = r_sizes[r_size]
112 | length = r_lengths[r_length]
113 | length = int(length[:-2])#remove mm
114 | rivet_type = r_types[r_type]
115 |
116 |
117 | return size, length, rivet_type
118 |
119 |
120 | def create_rivet():
121 | # *************************************************
122 | # *********** CREATE THE RIVET GEOMETRY ************
123 | # *************************************************
124 | size, length, type = get_rivet_properties()
125 | if type=='blind':
126 | #create a rivet object
127 | rivet = Blind(size, length)
128 | z = -rivet.length
129 | r = rivet.diameter/2
130 | pts=[]
131 | pts.append(Rhino.Geometry.Point3d(-r-1.5,0.0,0.0))
132 | pts.append(Rhino.Geometry.Point3d(-r-1.5,0.0,0.5))
133 | pts.append(Rhino.Geometry.Point3d(-r,0.0,1.0))
134 | pts.append(Rhino.Geometry.Point3d(-r+0.5,0.0,1.0))
135 | pts.append(Rhino.Geometry.Point3d(-r+0.5,0.0,z-0.5))
136 | pts.append(Rhino.Geometry.Point3d(-r-0.5,0.0,z-0.5))
137 | pts.append(Rhino.Geometry.Point3d(-r-0.5,0.0,z))
138 | pts.append(Rhino.Geometry.Point3d(-r,0.0,z))
139 | pts.append(Rhino.Geometry.Point3d(-r,0.0,0.0))
140 | pts.append(Rhino.Geometry.Point3d(-r-1.5,0.0,0.0)) #repeat first point
141 | polyline = Rhino.Geometry.Polyline(pts)
142 | line = Rhino.Geometry.Line(Rhino.Geometry.Point3d(0.0,0.0,0.0), Rhino.Geometry.Point3d(0.0,0.0,1.0))
143 |
144 | revolve = Rhino.Geometry.RevSurface.Create(polyline, line, 0.0, 2*math.pi)
145 | revolve = Rhino.Geometry.Brep.CreateFromRevSurface(revolve, False, False)
146 |
147 |
148 | #add objects to rivet
149 | rivet.breps.append(revolve)
150 |
151 | #scale objects
152 | rivet = set_scale(rivet)
153 |
154 | add_rivet(rivet)
155 |
156 | if type=='countersunk':
157 | #create a rivet object
158 | rivet = Countersunk(size, length)
159 | z = -rivet.length
160 | r = rivet.diameter/2
161 | pts=[]
162 | pts.append(Rhino.Geometry.Point3d(-r-1.5,0.0,0.0))
163 | pts.append(Rhino.Geometry.Point3d(-r-1.45,0.0,0.05))
164 | pts.append(Rhino.Geometry.Point3d(-r+0.45,0.0,0.05))
165 | pts.append(Rhino.Geometry.Point3d(-r+0.5,0.0,0.0))
166 | pts.append(Rhino.Geometry.Point3d(-r+0.5,0.0,z-0.5))
167 | pts.append(Rhino.Geometry.Point3d(-r-0.5,0.0,z-0.5))
168 | pts.append(Rhino.Geometry.Point3d(-r-0.5,0.0,z))
169 | pts.append(Rhino.Geometry.Point3d(-r,0.0,z))
170 | pts.append(Rhino.Geometry.Point3d(-r,0.0,-0.866))
171 | pts.append(Rhino.Geometry.Point3d(-r-1.5,0.0,0.0)) #repeat first point
172 | polyline = Rhino.Geometry.Polyline(pts)
173 | line = Rhino.Geometry.Line(Rhino.Geometry.Point3d(0.0,0.0,0.0), Rhino.Geometry.Point3d(0.0,0.0,1.0))
174 |
175 | revolve = Rhino.Geometry.RevSurface.Create(polyline, line, 0.0, 2*math.pi)
176 | revolve = Rhino.Geometry.Brep.CreateFromRevSurface(revolve, False, False)
177 |
178 |
179 | #add objects to rivet
180 | rivet.breps.append(revolve)
181 |
182 | #scale objects
183 | rivet = set_scale(rivet)
184 |
185 | add_rivet(rivet)
186 |
187 | def add_rivet(rivet):
188 | # ***********************************************
189 | # ******** ADDING THE RIVET TO THE SCENE *********
190 | # ***********************************************
191 | old_osnap_state = ModelAidSettings.OsnapModes #record Osnap state to reset later
192 |
193 | rivets=0
194 | rs.OsnapMode(32+134217728)
195 | while True:
196 | Rhino.UI.MouseCursor.SetToolTip("select surface or face")
197 | # this function ask the user to select a point on a surface to insert the bolt on
198 | # Surface to orient on
199 | gs = Rhino.Input.Custom.GetObject()
200 | gs.SetCommandPrompt("Surface to orient on")
201 | gs.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
202 | gs.Get()
203 | if gs.CommandResult()!=Rhino.Commands.Result.Success:
204 | ModelAidSettings.OsnapModes = old_osnap_state #reset to previous Osnap state
205 | print str(rivets) + " "+rivet.__repr__() + " rivet(s) added to the document"
206 | Rhino.UI.MouseCursor.SetToolTip("")
207 |
208 | return
209 |
210 | objref = gs.Object(0)
211 | # get selected surface object
212 | obj = objref.Object()
213 | if not obj:
214 | ModelAidSettings.OsnapModes = old_osnap_state #reset to previous Osnap state
215 |
216 | print str(rivets) + " "+rivet.__repr__() + " bolt(s) added to the document"
217 | return
218 |
219 | # get selected surface (face)
220 | global surface
221 | surface = objref.Surface()
222 | if not surface: return Rhino.Commands.Result.Failure
223 | # Unselect surface
224 | obj.Select(False)
225 |
226 | # Point on surface to orient to / activate center Osnap
227 |
228 | gp=Rhino.Input.Custom.GetPoint()
229 | gp.SetCommandPrompt("Point on surface to orient to")
230 | gp.Constrain(surface, False)
231 | #display the geometry to be created
232 | gp.DynamicDraw+=drawbreps
233 | gp.Get()
234 |
235 | if gp.CommandResult()!=Rhino.Commands.Result.Success:
236 | ModelAidSettings.OsnapModes = old_osnap_state #reset to previous Osnap state
237 | print str(rivets) + " "+rivet.__repr__() + " bolt(s) added to the document"
238 | return
239 |
240 | getrc, u, v = surface.ClosestPoint(gp.Point())
241 | if getrc:
242 | getrc, target_plane = surface.FrameAt(u,v)
243 | if getrc:
244 | # Build transformation
245 | source_plane = Rhino.Geometry.Plane.WorldXY
246 | xform = Rhino.Geometry.Transform.PlaneToPlane(source_plane, target_plane)
247 |
248 |
249 | #check if layer Block_Definitions exist, else create it
250 | if not rs.IsLayer("Block_Definitions"): rs.AddLayer("Block_Definitions")
251 |
252 | #check if layer with block name exists, else create it
253 | if not rs.IsLayer("Block_Definitions::"+rivet.name):
254 |
255 | block_layer = rs.AddLayer("Block_Definitions::"+rivet.name, color = (120,210,210))
256 |
257 |
258 |
259 |
260 | block_layer = "Block_Definitions::"+rivet.name
261 |
262 | layer_id = rs.LayerId(block_layer)
263 |
264 | layer_index = sc.doc.Layers.Find(layer_id, True)
265 | # Do the transformation
266 |
267 |
268 |
269 | rs.EnableRedraw(False)
270 | temp_layer = rs.CurrentLayer()
271 |
272 | rs.CurrentLayer(block_layer)
273 |
274 | objs=rivet.breps
275 | rhobj=[]
276 | for brep in objs :
277 |
278 | attribs = Rhino.DocObjects.ObjectAttributes()
279 | attribs.WireDensity = -1
280 | attribs.LayerIndex = layer_index
281 | rhobj.append(sc.doc.Objects.AddBrep(brep, attribs))
282 |
283 | rs.AddBlock(rhobj,[0,0,0],rivet.name, True)
284 |
285 | newrivet = rs.InsertBlock2(rivet.name, xform)
286 | rs.CurrentLayer(temp_layer)
287 | rs.EnableRedraw(True)
288 | rivets +=1
289 |
290 |
291 | def set_scale(rivet):
292 |
293 | scale = rm.UnitScale(sc.doc.ModelUnitSystem.Millimeters, sc.doc.ModelUnitSystem)
294 | xf=Rhino.Geometry.Transform.Scale(Rhino.Geometry.Plane.WorldXY, scale,scale,scale)
295 | for brep in rivet.breps:
296 | brep.Transform(xf)
297 | #copy to displaybreps for preview
298 | global displaybreps
299 | displaybreps = rivet.breps
300 |
301 | return rivet
302 |
303 | def drawbreps(gp, args ):
304 | getrc, u, v = surface.ClosestPoint(args.CurrentPoint)
305 | if getrc:
306 | getrc, target_plane = surface.FrameAt(u,v)
307 | xf = Rhino.Geometry.Transform.PlaneToPlane(Rhino.Geometry.Plane.WorldXY,target_plane)
308 |
309 | for brep in displaybreps:
310 | new = brep.Duplicate()
311 |
312 | new.Transform(xf)
313 | args.Display.DrawBrepWires(new, Color.FromArgb(255, 120, 210, 210), 0)
314 |
315 |
316 |
317 | if __name__ == "__main__":
318 | create_rivet()
319 |
--------------------------------------------------------------------------------
/thin_sheet_metal/simplified_sheet_metal.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/studiogijs/pythonscripts/d63fb964fe0c9dd1d908529eb464b1d5e6f82aaf/thin_sheet_metal/simplified_sheet_metal.gh
--------------------------------------------------------------------------------
/vray/Vray-Tools.rui:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
14 | Vray Tools
15 |
16 |
17 |
18 | Vray Tools
19 |
20 | 107618e9-33b8-4ccd-8df0-18d0cd7dd07d
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | Vray Tools
29 |
30 |
31 |
32 | Toolbar item 05
33 |
34 | b691d4b7-0ece-475a-b9f9-94473bbc40e5
35 | fa4815e3-f0df-4399-80a0-5fe5150ac1cc
36 |
37 |
38 |
39 | Toolbar item 04
40 |
41 | 43c99c34-da54-4cf5-b328-6280c7223fcf
42 | 808a3772-405a-4f11-abaa-d71e4148a45d
43 |
44 |
45 |
46 | Toolbar item 03
47 |
48 | 285b9d22-57a0-4ca6-a2e6-933d62fa68be
49 | 82c4ddd5-ae5b-4ced-8d10-d97c0deb14c7
50 |
51 |
52 |
53 | Toolbar item 01
54 |
55 | 7f3390ee-5771-44e6-a28e-a46ee04512f2
56 | 18a81bd1-0c81-422a-af67-cddbe95c32e1
57 |
58 |
59 |
60 | Toolbar item 00
61 |
62 | b9a6606a-29ef-48e4-b93c-acb03a346cb5
63 | a92b4b48-08f6-498e-8e44-da2f0d478b3d
64 |
65 |
66 | 9f04d2fc-758e-4004-9390-35393883c290
67 | e813a949-8704-405e-a588-4812f0190321
68 |
69 |
70 |
71 |
72 |
73 |
74 | Macro 17
75 |
76 |
77 | move light +100
78 |
79 |
80 | Macro 02
81 |
82 |
83 | moveLight_100
84 |
85 |
86 | Macro 02
87 |
88 |
89 |
90 |
91 |
92 | Macro 03 - Copy - Copy - Copy - Copy 00 - Copy - Copy 00 - Copy - Copy - Copy - Copy
93 |
94 |
95 | move light -100
96 |
97 |
98 | Macro 03
99 |
100 |
101 | moveLight_100
102 |
103 |
104 | Macro 03
105 |
106 |
107 |
108 |
109 |
110 | Macro 18
111 |
112 |
113 | move light +10
114 |
115 |
116 | Macro 02
117 |
118 |
119 | moveLight_10
120 |
121 |
122 | Macro 02
123 |
124 |
125 |
126 |
127 |
128 | Macro 03 - Copy - Copy - Copy - Copy 00 - Copy - Copy 00 - Copy - Copy - Copy - Copy 00
129 |
130 |
131 | move light -10
132 |
133 |
134 | Macro 03
135 |
136 |
137 | moveLight_10
138 |
139 |
140 | Macro 03
141 |
142 |
143 |
144 |
145 |
146 | Macro 14
147 |
148 |
149 | Focus Spotlight(s)
150 |
151 |
152 | Macro 02
153 |
154 |
155 | FocusSpots
156 |
157 |
158 | Macro 02
159 |
160 |
161 |
162 |
163 |
164 | Macro 03 - Copy - Copy - Copy - Copy 00 - Copy - Copy 00 - Copy
165 |
166 |
167 | advanced
168 |
169 |
170 | Macro 03
171 |
172 |
173 | FocusSpots
174 |
175 |
176 | Macro 03
177 |
178 |
179 |
180 |
181 |
182 | Macro 13
183 |
184 |
185 | Swap X and Y resolution
186 |
187 |
188 | Macro 02
189 |
190 |
191 | SwapRes
192 |
193 |
194 | Macro 02
195 |
196 |
197 |
198 |
199 |
200 | Macro 03 - Copy - Copy - Copy - Copy 00 - Copy - Copy 00
201 |
202 |
203 | -
204 |
205 |
206 | Macro 03
207 |
208 |
209 | SwapRes
210 |
211 |
212 | Macro 03
213 |
214 |
215 |
216 |
217 | Macro 11
218 |
219 |
220 | resolution double
221 |
222 |
223 | Macro 02
224 |
225 |
226 | double/half-res
227 |
228 |
229 | Macro 02
230 |
231 |
232 |
233 |
234 |
235 | Macro 03 - Copy - Copy - Copy - Copy 00 - Copy
236 |
237 |
238 | resolution half
239 |
240 |
241 | Macro 03
242 |
243 |
244 | double/half-res
245 |
246 |
247 | Macro 03
248 |
249 |
250 |
251 |
252 |
253 | Macro 12
254 |
255 |
256 | A4 @ 300dpi
257 |
258 |
259 | Macro 02
260 |
261 |
262 | A4 | A3
263 |
264 |
265 | Macro 02
266 |
267 |
268 |
269 |
270 |
271 | Macro 03 - Copy - Copy - Copy - Copy 00 - Copy - Copy
272 |
273 |
274 | A3 @ 300dpi
275 |
276 |
277 | Macro 03
278 |
279 |
280 | A4 | A3
281 |
282 |
283 | Macro 03
284 |
285 |
286 |
287 |
288 |
289 | Macro
290 |
291 |
292 |
293 |
294 | Macro 00
295 |
296 |
297 | position light by reflection
298 |
299 |
300 | ReflectLight
301 |
302 |
303 |
304 |
305 |
306 | Macro 01
307 |
308 |
309 | -
310 |
311 |
312 | ReflectLight
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 | 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
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 | 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
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 | 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
488 |
489 |
490 |
491 |
--------------------------------------------------------------------------------
/vray/changeRes.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 |
3 | def changeRes():
4 | """
5 | This script scales the resolution by user specified factor.
6 | Typically use this in a toolbar, where you can pass the scale factor directly
7 | script by Gijs de Zwart
8 | www.studiogijs.nl
9 | """
10 | i=rs.GetReal(number=2, minimum=0.1)
11 | vray = rs.GetPlugInObject("V-Ray for Rhino")
12 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_width")
13 | param.Value = int(param.Value()*i)
14 | width = param.Value()
15 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_height")
16 | param.Value = int(param.Value()*i)
17 | height = param.Value()
18 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_aspect_ratio")
19 | param.Value = 5
20 | print "image resolution set to %d by %d" %(width, height)
21 | changeRes()
22 |
--------------------------------------------------------------------------------
/vray/customRes.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 | import System
3 | def changeRes():
4 | """
5 | With this script you can change the resolution through the command line.
6 | Typically use this in a toolbar, where you can pass the x and y relolution directly
7 | script by Gijs de Zwart
8 | www.studiogijs.nl
9 | """
10 | width = rs.GetInteger(number = 1024)
11 | height = rs.GetInteger(number=768)
12 | vray = rs.GetPlugInObject("V-Ray for Rhino")
13 |
14 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_pixelAspect")
15 | param.Value=5
16 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_aspect_ratio")
17 | param.Value=5
18 |
19 |
20 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_width")
21 |
22 | param.Value = width
23 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_height")
24 | param.Value = height
25 |
26 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_aspect_ratio_height")
27 | param.Value = System.Single(1)
28 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_aspect_ratio_width")
29 | param.Value = System.Single(width/height)
30 | param = vray.Scene().Plugin("/SettingsOutput").Param("lock_resolution")
31 | param.Value = True
32 | vray.RefreshUI()
33 |
34 | changeRes()
35 |
--------------------------------------------------------------------------------
/vray/guessHorizontalShift.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import rhinoscriptsyntax as rs
3 | import math
4 | import System
5 |
6 | def Main(option):
7 | if option == 0:
8 | guessHorizontalShift()
9 | if option == 1:
10 | resetHorizontalShift()
11 | if option == 2:
12 | printHorizontalShift()
13 | else:
14 | return
15 |
16 | def guessHorizontalShift():
17 |
18 | """
19 | This script will correct the horizontal distortion and set it in the V-Ray Camera.
20 | It levels the camera for this correction to work well and resets
21 | lens shift (vertical shift) to 0
22 | Works with V-Ray 5.1
23 |
24 | version 0.4
25 |
26 | www.studiogijs.nl
27 | """
28 | viewport = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport
29 | if viewport.IsParallelProjection:
30 | print "Stupid, you should select a perspective view"
31 | return
32 | view = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport
33 | #set camera location to target height
34 | pt = view.CameraLocation
35 | pt[2] = view.CameraTarget.Z
36 | dir = rs.VectorSubtract(view.CameraTarget, pt)
37 | view.SetCameraLocation(pt, False)
38 | view.SetCameraDirection(dir, False)
39 |
40 |
41 | #calculate camera direction angle relative to WorldXY plane
42 | cam = view.CameraZ
43 | vec = Rhino.Geometry.Vector3d(1,0,0)
44 | plane = Rhino.Geometry.Plane.WorldXY
45 | angle = Rhino.Geometry.Vector3d.VectorAngle(cam, vec, plane)
46 |
47 | #calculate the correction factor
48 | for i in range(3):
49 | if angle>math.pi/2:
50 | angle-=math.pi/2
51 | else:
52 | break
53 |
54 | if 0 <= angle < math.pi/4:
55 | factor = math.tan(angle)
56 |
57 | if math.pi/4 <= angle < math.pi/2:
58 | factor = -math.tan(math.pi/2-angle)
59 |
60 |
61 | rv = rs.GetPlugInObject("V-Ray for Rhino").Scene().Plugin("/CameraPhysical")
62 | rv.Param("horizontal_shift").Value = factor
63 | print "Horizontal shift factor set to %r." %factor
64 | rv.Param("lens_shift").Value = 0
65 | rs.Redraw()
66 |
67 | def resetHorizontalShift():
68 | rv = rs.GetPlugInObject("V-Ray for Rhino").Scene().Plugin("/CameraPhysical")
69 | rv.Param("horizontal_shift").Value = 0
70 |
71 | def printHorizontalShift():
72 | rv = rs.GetPlugInObject("V-Ray for Rhino").Scene().Plugin("/CameraPhysical")
73 | print rv.Param("horizontal_shift").Value()
74 |
75 | if __name__ == "__main__":
76 | option = rs.GetInteger("0 guessHorizontalShift | 1 resetHorizontalShift | 2:printHorizontalShift ",number=0)
77 | Main(option)
--------------------------------------------------------------------------------
/vray/moveLight.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 |
3 | def moveLight():
4 | """
5 | Use this script to move a light in the direction it is aimed.
6 | Positive values are in the direction it aimed at.
7 | Typically use this in a toolbar, where you can pass the distance directly.
8 | script by Gijs de Zwart
9 | www.studiogijs.nl
10 | """
11 | distance = rs.GetInteger(number=10)
12 | object = rs.GetObject("select light to move in normal direction", preselect=True, filter=256)
13 | if not object:
14 | return
15 | light = rs.coercerhinoobject(object)
16 | dir = light.LightGeometry.Direction
17 | dir.Unitize()
18 | trans=dir*distance
19 | rs.MoveObject(object, trans)
20 | rs.SelectObject(object)
21 | if __name__ == "__main__":
22 | moveLight()
--------------------------------------------------------------------------------
/vray/reflectLight.py:
--------------------------------------------------------------------------------
1 | import Rhino
2 | import math
3 | import scriptcontext as sc
4 | import rhinoscriptsyntax as rs
5 |
6 |
7 |
8 | def reflectLight():
9 |
10 | """
11 |
12 | This script will place a (pre)selected light on a surface, polysurface, subd or mesh face by reflection
13 | After the script has run, it will select the modified light, so you can quickly repeat
14 | the placement with this light
15 | script by Gijs de Zwart
16 | www.studiogijs.nl
17 |
18 | """
19 |
20 | object = rs.GetObject("select light", preselect=True, filter=262400)
21 |
22 | if not object:
23 | return
24 | light = rs.coercerhinoobject(object)
25 | loc=light.LightGeometry.Location
26 | dir=light.LightGeometry.Direction
27 |
28 |
29 | obj = rs.GetObject("select surface to reflect light on", filter=40, subobjects=True)
30 |
31 | if not obj:
32 | return
33 | if type(rs.coercerhinoobject(obj))==Rhino.DocObjects.BrepObject or type(rs.coercerhinoobject(obj))==Rhino.DocObjects.SubDObject:
34 | pt = rs.GetPointOnSurface(obj)
35 | if not pt:
36 | return
37 | pt_srf = rs.SurfaceClosestPoint(obj, pt)
38 | if not pt_srf:
39 | print "could not find surface point"
40 | return
41 | normal = rs.SurfaceNormal(obj, pt_srf)
42 | if not normal:
43 | print "could not calculate surface normal"
44 | return
45 |
46 | else:
47 | pt = rs.GetPointOnMesh(obj)
48 | if not pt:
49 | return
50 | pt_mesh, index = rs.MeshClosestPoint(obj, pt)
51 | if not pt_mesh:
52 | print "could not find mesh point"
53 | normals = rs.MeshFaceNormals(obj)
54 | if normals:
55 | normal = normals[index]
56 | if not normal:
57 | print "could not calculate surface normal"
58 | return
59 |
60 | camLoc = sc.doc.Views.ActiveView.ActiveViewport.CameraLocation
61 | camTar = sc.doc.Views.ActiveView.ActiveViewport.CameraTarget
62 | camDir = sc.doc.Views.ActiveView.ActiveViewport.CameraDirection
63 |
64 | plane = Rhino.Geometry.Plane(pt, normal, -camDir)
65 | #sc.doc.Views.ActiveView.ActiveViewport.SetConstructionPlane(plane)
66 | #line = Rhino.Geometry.Line(camLoc, pt)
67 | #trans = Rhino.Geometry.Transform(angleRadians,rotationAxis, rotationCenter)
68 | trans = Rhino.Geometry.Transform.Rotation(math.pi, normal, pt)
69 | #rs.RotateObject(line, pt, 180, plane.XAxis, copy=True)
70 |
71 | #line.Transform(trans)
72 | camLoc.Transform(trans)
73 |
74 |
75 | newdir = rs.VectorCreate(pt, camLoc)
76 | newdir.Unitize()
77 | newplane = rs.PlaneFromNormal(camLoc, newdir)
78 | if light.LightGeometry.IsRectangularLight:
79 |
80 | lightX=light.LightGeometry.Width
81 | lightWidth = lightX.Length
82 | lightY=light.LightGeometry.Length
83 | lightHeight = lightY.Length
84 | lightO=light.LightGeometry.Location
85 |
86 |
87 | lightX = lightWidth * newplane.XAxis
88 | lightY = lightHeight * newplane.YAxis
89 | light.LightGeometry.Width = lightX
90 | light.LightGeometry.Length = lightY
91 |
92 | camLoc-=lightX/2
93 | camLoc-=lightY/2
94 | light.LightGeometry.Location = camLoc
95 |
96 | #mid = Rhino.Geometry.Vector3d(lightWidth/2, lightHeight/2, 0)
97 | #trans = Rhino.Geometry.Transform.ChangeBasis(Rhino.Geometry.Plane.WorldXY, lightPlane)
98 | #mid.Transform(trans)
99 | #light.LightGeometry.Location -=mid
100 | if light.LightGeometry.IsSpotLight:
101 | light.LightGeometry.Location = camLoc
102 | newdir*= rs.VectorLength(dir)
103 | light.LightGeometry.Direction = newdir
104 |
105 | #sc.doc.Objects.AddLine(line)
106 |
107 | sc.doc.Lights.Modify(object, light.LightGeometry)
108 | rs.SelectObject(object)
109 |
110 | reflectLight()
--------------------------------------------------------------------------------
/vray/swapRes.py:
--------------------------------------------------------------------------------
1 | import rhinoscriptsyntax as rs
2 |
3 | def swapRes():
4 | """
5 | This script script swaps x and y resolution.
6 | Typically useful for standard formats (together with changeRes.py) to switch between portrait and landscape
7 | script by Gijs de Zwart
8 | www.studiogijs.nl
9 | """
10 | vray = rs.GetPlugInObject("V-Ray for Rhino")
11 |
12 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_pixelAspect")
13 | param.Value=5
14 | param = vray.Scene().Plugin("/SettingsOutput").Param("img_aspect_ratio")
15 | param.Value=5
16 | param = vray.Scene().Plugin("/SettingsOutput").Param("lock_resolution")
17 | param.Value = False
18 |
19 | param1 = vray.Scene().Plugin("/SettingsOutput").Param("img_width")
20 | width = param1.Value()
21 |
22 | param2 = vray.Scene().Plugin("/SettingsOutput").Param("img_height")
23 | height = param2.Value()
24 | param1.Value = height
25 | param2.Value = width
26 | vray.RefreshUI()
27 | print "x resolution is now %d and y %d" %(height, width)
28 | swapRes()
29 |
--------------------------------------------------------------------------------