Jump to content

BillW

Member
  • Content Count

    32
  • Joined

  • Last visited

Community Reputation

0 Neutral

About BillW

  • Rank
    Greenhorn

Personal Information

  • Occupation
    Architect
  • Location
    UK

Recent Profile Visitors

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

  1. Thanks. Managed to get things working.
  2. Marissa did a quick test. I tried using the #COMMAND line ie using [UsrLib] which failed with message dialog "The referenced file was not found" I then tried the full path to the file - see attached image - got the same message. The file does exist (on PC) - see below Will keep on trying. Could it be a case sensitive issue with .PY instead of .py
  3. Thanks. I did all of the above and have a functioning user library. My question was can I add nodes to the Marionette Default Library node list. If I craft some NURBS nodes for example, I don't want two locations for NURBS nodes (one set in Default library and another set in User library). I suppose I could have my own version of the Default library which would need to be updated at subsequent Vectorworks releases. Will probably just stick with my User library setup. As an aside, for a user library can the code be stored in .py files similar to Default library. Default nodes have a first line in the script: #COMMAND;READONLYREFFILE;[VWLibDef]/Input\Point2.py; Is there an equivalent path to "VWLibDef" for user nodes (for example UserLibDef)
  4. I have a bunch of nodes which I would like to embed in the standard Marionette tool list. I understand the standard nodes are stored in (PC) "Program files/Vectorworks 2018/Libraries/Defaults/Marionette/Marionette Default Library.vwx" I can setup a separate User defined list of nodes by placing my library file in for example "Users/<username>/Appdata/Roaming/Nemetschek/Vectorworks/2018/Libraries/Defaults/Marionette/Marionette User Library.vwx" What do I need to do to embed user nodes in the standard Marionette tool list? I did notice some folders in the user location ie Attributes$ , Math$ , Textures$ and Objects/NURB$ but I am not sure how to use/implement them. Can I create a new category ie Tools$ It's been quite interesting using Marionette as a front end to plugin objects. TIA
  5. Why not use Python equivalent of PointAlongPoly(h: HANDLE; dist: REAL; VAR ptX, ptY, ptZ: REAL; VAR tangentX, tangentY, tangentZ: REAL) : BOOLEAN; Always a good idea to check file "VWPluginLibraryRoutines.p" in user plugins folder for non documented calls.
  6. BillW

    Shorten Nurbs curve

    Still trying to understand Nurbs particularly how knot values work. Still cant figure out the logic for knot values in all cases - see below (might help others understanding). Please comment if the information is incorrect. I have also noticed when I "Export to script" a nurbs curve with more than 1 piece (ie from NurbsCurveGetNumPieces and with different degree values), if imported (via the script) a nurbs curve is created for each piece. There doesn't seem to be a way of creating (via script) a multi piece nurbs curve as far as I can tell. To solve my problem, I think I will have to convert the (mutli piece) nurbs curve to 3D polygons (one for each piece, grouped), create/modify the 3D polygons and convert back to nurbs. I need the nurbs for internal workings of path based plugins.
  7. BillW

    Shorten Nurbs curve

    I am trying to shorten a nurbs curve. There is an "ExtendNurbsCurve" function but no shorten option. I can move the start point of a nurbs curve with the following code curveH := CreateDuplicateObject(srcH,NIL); if (startoffset > 0) then begin curvelen := hlength(srcH); inPercentOfLength := startoffset / curvelen; if GetPointAndParameterOnNurbsCurveAtGivenLength(curveH,inPercentOfLength,px,py,pz,outParam,outIndex) then begin NurbsSetPt3D(curveH,0,outIndex,px,py,pz); resetobject(curveH); end; end; The problem is with getting the curve alignment correct. I assume I have to set the correct knot values for curve vertex points 0 and 1 with NurbsSetKnot(objH,curveH,0,0) and NurbsSetKnot(objH,curveH,0,1). I can get the existing knot values with NurbsKnot(srcH,curveH,0,0) and NurbsKnot(objH,srcH,0,1) . The question is how will the knot values change - what is the relationship? TIA Bill Wood
  8. BillW

    Generating Popup Control dynamic content

    That's the problem solved. Thanks vey much. Bill Wood
  9. BillW

    Generating Popup Control dynamic content

    Marissa, I loaded your script into my VW file - see attached. Weird, I still cannot get it to run. The VW file has popups which do run. I am on Windows 7 Professional SP1 and VW 2018 SP1. Previously, I pretty much made the same sort of edits as your version. angle test.vwx
  10. BillW

    Generating Popup Control dynamic content

    Marissa, I tried your suggestions but still cannot get any output ie from Marionette.PortOut('Type') even with debug set. I tried various things including merging the content and params classes, replacing the .nodename and .nodedesc with fixed strings and even externally building the getcontent() full string and embedding as a fixed string. I even upgraded Vectorworks 2018 to SP 1 and set Marionette preferences>Cache Last Run in Debug On and Off. I have the feeling that Marionette.WidgetType.Popup does not like long lists. I also understand that by default the popup widget returns a number relating to the selected item from the list. Can you try at your end to see if you can get it to work - it might be my VW installation.
  11. BillW

    Generating Popup Control dynamic content

    Thanks Marissa. I managed to get the popup filled with content from a standard plugin data file - see below. For some reason I cannot get any output from the node ie self.Params.sectionsize.value = sectionType Tried passing the output to an alertdialog node - nothing. Is it the definition of class content before @Marionette.NodeDefinition causing the problem. import os class content: nodename = "Angle-Metric" nodedesc = 'Select an Angle-Metric section size' def getcontent(): fref = os.path.join(vs.GetFolderPath(20) , 'Angle-Metric.txt' ) content = [] if os.path.exists(fref): f = open(fref) line = f.readline() # First line not used line = f.readline() while line: sline = line.split('\t',1) content.append(sline[0]) line = f.readline() f.close() else: content = ['Undefined'] return content @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): #APPEARANCE #Name this = Marionette.Node( content.nodename ) this.SetDescription( content.nodedesc ) #OIP Controls sectionType = Marionette.OIPControl('Section Type', Marionette.WidgetType.Popup, 0, content.getcontent() ) sectionType.SetDescription( "List of valid section types" ) #Output Ports sectionsize = Marionette.PortOut('Type') sectionsize.SetDescription( "The resultant section definition" ) #BEHAVIOR def RunNode(self): #inputs sectionType = self.Params.sectionType.value #outputs self.Params.sectionsize.value = sectionType
  12. Trying to tie some of my tools into Marionette. Before diving in further, is it possible to dynamically fill a popup controls choice content from say a text file? Can I add a function to class Params and reference in the OIPControl definition (ie this.getcontent('options.txt')) - see below (example from Marionette website) TIA Bill Wood @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): this = Marionette.Node( 'Add' ) a = Marionette.PortIn( 0 ) b = Marionette.PortIn( 0 ) out = Marionette.PortOut() k = Marionette.OIPControl( 'Multiplier', Marionette.WidgetType.Real, 1) p10 = Marionette.OIPControl( 'Popup', Marionette.WidgetType.Popup, 0, ['choice 1', 'choice 2']) def RunNode(self): sum = self.Params.a.value + self.Params.b.value self.Params.out.value = sum * self.Params.k.value
  13. BillW

    Angle sense between 3 points

    Raymond Thanks for the code, much simpler. In the desperate need to finish the code, I didn't see/manage to pick up your code in time. I did it a slightly different way which seems to work fine - see below Thanks anyway. Bill Wood procedure getpolydef(polyH : HANDLE; vertnum : INTEGER); Var j : INTEGER; p1,p2,p3 : VECTOR; v1,v2 : VECTOR; ang,testang : REAL; ang1,ang2 : REAL; begin for j := 1 to vertnum do begin GetPolyPt(polyH ,j,p2.x,p2.y); {test vertex} if (j = numvert) then GetPolyPt(polyH,1,p3.x,p3.y) {next vertex} else GetPolyPt(objH,j+1,p3.x,p3.y); if (j=1) then GetPolyPt(objH,numvert,p1.x,p1.y) {previous vertex} else GetPolyPt(objH,j-1,p1.x,p1.y); pathdef[j].x := p2.x; pathdef[j].y := p2.y; ang := Rad2Deg(ArcCos(DotProduct(UnitVec(p1-p2), UnitVec(p3-p2)))); {angle between 3 points always positive} v1.x := p2.x-p1.x; v1.y := p2.y-p1.y; v2.x := p3.x-p1.x; v2.y := p3.y-p1.y; ang1 := vec2ang(v1); ang2 := vec2ang(v2); testang := ang1-ang2; {work out angle direction from test point to to point} if testang >= 180 then pathdef[j].angle := -ang else if testang >= 0 then pathdef[j].angle := ang else if testang < -180 then pathdef[j].angle := ang else pathdef[j].angle := -ang; end; end; {getpolydef}
  14. Banging my head against the wall on this one. I am testing a polygon. If I have 3 vertices, "start point", "test point", "to point" - I can test the angle between the 3 points using the logic of the developer example PROCEDURE Example; VAR pt1, pt2, pt3, pt4 :VECTOR; ang :REAL; BEGIN GetPt(pt1.x, pt1.y); {start point} GetPtL(pt1.x, pt1.y, pt2.x, pt2.y); {test point} GetPtL(pt2.x, pt2.y, pt3.x, pt3.y); {to point} MoveTo(pt1.x, pt1.y); LineTo(pt2.x, pt2.y); LineTo(pt3.x, pt3.y); pt4 := (pt1 + pt3) / 2; {Find the angle between the vectors.} ang := Rad2Deg(ArcCos(DotProduct(UnitVec(pt1-pt2), UnitVec(pt3-pt2)))); TextOrigin(pt4.x, pt4.y); CreateText(Concat(ang)); END; RUN(Example); This always returns a positive angle. What I need to find out is if the "to point" is to the left (-ive) or right (+ive) of a vector "start point" to "test point" I tried comp(p2-p1,p3-p1,v3,v4) with v4 orthogonal to p2-p1 I thought I could test v4.y for +ive or -ive sense but cant seem to get it to work. TIA Bill Wood
  15. BillW

    vs.GetPt()

    For a tool I think you can try x1,y1 = vs.vstGetCurrPt2D() or - not tried in code yet outX, outY, outZ = vs.vstGetCurrPt3D(result) As an aside I had a Vectorscript tool with Getpt(x1,y1) Getptl(x1,y1,x2,y2) {rubberband line} and couldn't get the Python version of Getptl to work.

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×