Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5800

Help with getting my polyline script to use osnaps

$
0
0

@DreamPsi wrote:

hi I'm very new to scripting so ill be short. after about all night and into the morning I finally found a way to script the poly line tool just like in the program... because its the example that was given by rhino team.... but the point is it works and it does use osnaps just not on the lines that are being generated from start of script use until you end the script. how ever running the script again lets you osnap to the prior polyline created from it but not during its creation any help would be appreciated.

import scriptcontext 
import rhinoscriptsyntax as rs
import math 
import System.Guid, System.Array, System.Enum 
#this is the code that the actuall tool in rhino acesses from but its not entirely the same
def AddPolyline(points, replace_id=None): 
     points = rs.coerce3dpointlist(points, True) 
     if replace_id: replace_id = rs.coerceguid(replace_id, True) 
     rc = System.Guid.Empty 
     pl = Rhino.Geometry.Polyline(points) 
     pl.DeleteShortSegments(scriptcontext.doc.ModelAbsoluteTolerance) 
     if replace_id: 
         if scriptcontext.doc.Objects.Replace(replace_id, pl): 
             rc = replace_id 
     else: 
         rc = scriptcontext.doc.Objects.AddPolyline(pl) 
     if rc==System.Guid.Empty: raise Exception("Unable to add polyline to document") 
     scriptcontext.doc.Views.Redraw() 
     return rc        
     
     
#And this is what draws the poly line
pointes = rs.GetPoints(True)
if pointes: rs.AddPolyline(pointes)

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5800

Trending Articles