Jump to content

Letti R

Member
  • Posts

    13
  • Joined

Reputation

11 Good

Personal Information

  • Location
    Germany

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Letti R

    hgarnade

    Hello, thank you for the reply @Antonio Landsberger, but i should have stated that i am not using marionette for this project anymore. Here is a video of the current state of the plugin, maybe @hgarnade and @Kevin McAllister can tell me if this is usable. Regards, Letti prototype_2D mill_presentation.mp4
  2. Letti R

    hgarnade

    Hello, i turned my previously posted marionette node (which to my shame i have to admit has many errors) into a tool. I tried to replicate the functions of a script for rhino which i found online. The tool can now add "bones" to corners like this: The tool can create "bones" on every corner regardless of the angle. It works on closed polygons and closed polylines, but not yet on polylines with holes. Creating your own holes should still be easy because the tool can also add "bones" to convex corners. The tool works by clicking on the corners where you want to draw a "bone". It is also possible to draw the same kind of "bone" on every corner of the polygon that is of the same type (concave or convex) as the corner you clicked on. Please message me if you want to try this tool. I dont want to post it publicly yet. Regards Letti
  3. Letti R

    hgarnade

    Hello, based on your posts i wrote a little marionette node as a first prototype for a script that maybe can handle this. Please note that i dont have any experience in cnc milling, so i rely on your feedback. Here is the code, simply cope paste the whole code into an existing marionette node and it should work. This is meant to be just the very first prototype of a script. I just want to know if this is the right direction before i put more effort in it. # by Letti R, 2022 07 19 @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): #APPEARANCE #Name this = Marionette.Node( "2D mill_dog bone" ) this.SetDescription( '2D mill_dog bone' ) #Input Ports poly = Marionette.PortIn( vs.Handle(0), 'hPoly' ) poly.SetDescription( "The input poly" ) #OIP Controls bit_diameter = Marionette.OIPControl( 'bitDiameter', Marionette.WidgetType.RealCoord, 0.0) bit_diameter.SetDescription('bitDiameter') side = Marionette.OIPControl( 'side', Marionette.WidgetType.Popup, 0, ['right', 'left']) side.SetDescription('side') #Output Ports #BEHAVIOR this.SetLinksObjects() def RunNode(self): #inputs poly = self.Params.poly.value bit_diameter = self.Params.bit_diameter.value / vs.GetPrefReal(150) side = self.Params.side.value epsilon = 0.000000001 #functions def cross_2D(vector_1, vector_2): if len(vector_1) == len(vector_2) and len(vector_1) == 2: return(vector_1[0]*vector_2[1] - vector_2[0]*vector_1[1]) else: return(None) def two_tuples_to_vector(tuple_1, tuple_2): lt1 = len(tuple_1) lt2 = len(tuple_2) if lt1 == lt2: list_subtractions = [] for i in range(lt1): list_subtractions.append(tuple_2[i] - tuple_1[i]) return(tuple(list_subtractions)) else: return(None) def rotate_list(list, n): return(list[n:] + list[:n]) def normalize_tuple(tup): tup_squared = [] for item in tup: tup_squared.append(item**2) len_tup = math.sqrt(sum(tup_squared)) norm_list = [] for item in tup: norm_list.append(item / len_tup) return(tuple(norm_list)) def vector_angle_bisector(vector_1, vector_2): normalized_vector_1 = normalize_tuple(vector_1) normalized_vector_2 = normalize_tuple(vector_2) return(normalize_tuple((normalized_vector_1[0] + normalized_vector_2[0], normalized_vector_1[1] + normalized_vector_2[1]))) #script poly_vertecies = [] for i in range(vs.GetVertNum(poly)): poly_vertecies.append(vs.GetPolylineVertex(poly, i+1)[0]) vectors_to_this_points = [] for i in range(len(poly_vertecies)): vector_temp_1 = two_tuples_to_vector(poly_vertecies[i-2], poly_vertecies[i-1]) vector_temp_2 = two_tuples_to_vector(poly_vertecies[i], poly_vertecies[i-1]) vectors_to_this_points.append((vector_temp_1, vector_temp_2)) vectors_to_this_points = rotate_list(vectors_to_this_points, 1) cross_product_of_vectors_to_points = [] for vectors in vectors_to_this_points: cross_product_of_vectors_to_points.append(cross_2D(vectors[0], vectors[1])) for i in range(len(poly_vertecies)): if bit_diameter and abs(cross_product_of_vectors_to_points[i]) >= epsilon: run_script = False if side == 0 and cross_product_of_vectors_to_points[i] < 0: run_script = True elif side == 1 and cross_product_of_vectors_to_points[i] > 0: run_script = True if run_script: temp_vector_angle_bisector = vector_angle_bisector(vectors_to_this_points[i][0], vectors_to_this_points[i][1]) vs.MoveTo(poly_vertecies[i]) vs.LineTo((poly_vertecies[i][0] + ((bit_diameter / 2) * temp_vector_angle_bisector[0]), poly_vertecies[i][1] + ((bit_diameter / 2) * temp_vector_angle_bisector[1]))) #outputs Regards Letti
  4. Hello, i tried to make the 2D part of your project 1.0. I think doing this only with marionette (without custom nodes) is not easy (maybe even impossible). I tried to make a marionette for one 2D polygon and it works fine, but if i want to be able to process multiple 2D polygons at once i come to a point where i would need to write my own nodes. But instead of writing my own nodes i would rather write the whole script in python. However there are workarounds for the 2D part. 1. Convert your import into lines manually and make a marionette for lines: The marionette for lines in 2D could look something like this, but i dont recommend doing it this way. 2. Convert your import into lines manually and make data visualisations: For 2D lines you can achive something like what you want with data visualisations. Simply make a visualisation for lines with a "Bounding Box delta x" of 0 (line is parallel to y), and one for lines with a "Bounding Box delta y" of 0 (line is parallel to x). Regards Letti
  5. Hello, This was the solution. Now the Images are also shown on a mac. Thanks alot for the help. Regards, Letti
  6. Hello, thanks for your reply. Im sorry for not pointing out that i already set up my images like that, but it still does not work. MyTool.vwr/Images/MyImage.png (26x20 pixel, 72dpi) MyTool.vwr/Images/MyImage@2x.png (52x40 pixel, 144dpi) And in the .cpp file i wrote it like this: TXStringArray imageSpecs; imageSpecs.Append("MyTool/Images/MyImage"); Is that enough or do i have to do something like: if operating system is mac imageSpecs.Append("MyTool/Images/MyImage@2x"); Unfortunately i cant just try it, because i dont have access to a mac right now. Regards, Letti
  7. Hello, i just "finished" the first verion of my tool and when i compile it for windows everything works just fine. But when i compile the tool for macOS, the images in the mode bar (only in the mode bar) are missing (it shows an image of a red "x" instead of my image). Could this be because of the resolution of the mac i was testing on (4k)? And how do i add the "2x" images for the screens with high resolution? Also i think i did not set up or install the SDK on the mac correctly. Unfortunately i am not familiar in working with a mac. Is there a recent, easy to follow guide about how to setup the SDK and xcode? Regards, Letti
  8. Hello, thank you for your answers. This helped me alot. Regards, Letti
  9. Hello, i want my tool to change the action that is needed to run, based on the mode that is selected in the mode bar. Unfortunately i cant find a fitting example, or i am overlooking it. The tool should behave like this: - First mode -> Run the tool after clicking on the drawing - Second mode -> Run the tool after clicking in 3d and catching the 3d point - Third mode -> Run the tool after drawing a line in 3d and catching start and end point How can i do this? I hope someone can point me in the right direction. (Sidenote: I am new to working with the SDK and new to writing in C++) Regards, Letti
  10. Hello, i tried to use this in a tool. Unfortunately i found this function to be inconsistent at least when used in a tool that is called by a click. After i selected the tool, sometimes the first click on the drawing (i assume this is the click that runs the code) is the first point of the line, and sometimes i need another click on the drawing to start the line. In your example this is not too bad, because the vs.CallTool() function is called right at the start of the script. But i wanted the first click on the drawing to just open an UI and than call the vs.CallTool() according to the mode that had been chosen in the UI. I also tried to call the vs.CallTool() function two times in a row, but i always crashed vectorworks.
  11. Hello, there is a VS Function that converts an angle into a vector. You can look it up here. With that Function you can write your own Marionette Node. In Python it could look something like this: @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): #APPEARANCE #Name this = Marionette.Node( 'Angle to Vector' ) this.SetDescription( 'Converts an angle in degrees to a 2D vector' ) #Input Ports nAngle = Marionette.PortIn(0) nAngle.SetDescription( 'an angle in degrees' ) nLength = Marionette.PortIn(1) nLength.SetDescription( 'the length of the output vector' ) #OIP Controls #Output Ports v = Marionette.PortOut() v.SetDescription( 'a 2D vector' ) #BEHAVIOR def RunNode(self): #inputs nAngle = self.Params.nAngle.value nLength = self.Params.nLength.value #script v = vs.Ang2Vec(nAngle, nLength) #outputs self.Params.v.value = v But, as shown in the example below, in some cases the VS function returns realy small numbers instead of zeros. So i would recommend to round the returned values to a reasonable length.
  12. Hello, if the text is always just centered you can also use the "get 2D Center" Node. Then the Network could look like this: This Network uses the 2D information of the text object and takes advantage of the fact that the 2D center of the text object is the same as the center of the text (or at least i hope it always is). Like this you dont have to worry about the vectorworks preferences. Notes: - The network shown above only works for inserting the text object at its center - Although the insertion point of the text object ist its center, the text can be aligned differently - You can change the "Get 2D Center" node to the "Get 2D Point" to use one of the 4 vertecies of the text object as the insertion point
  13. Hello, although i would not recommend it, this is another way you can do it with built in nodes only and without using the "function" node.
×
×
  • Create New...