The Hamma Posted October 5, 2021 Share Posted October 5, 2021 I have written a script and created a "Symbol Legend (custom plugin)" tool. It works great except for one issue. When the symbol is a data tag the symbol the tag symbol does not appear. If I explode the plugin the symbol appears. This only happens when there is a description to type on the screen or if there is a second symbol in the resource browser. If there is no description the tag does appear. Tag is the only symbol in the drawing Tag and Watercloset symbol are in drawing. VSO attached. """ This script inserts all of the symbols in the current drawing resource manager into the drawing with the text in Record "Legend Record" and field "Legend Text" if assigned to a symbol. It ignores symbols with the record but no text in the "Legend Text" Field. First run will create "Legend Record" if it does not exist. This Python Script may be freely distributed. No warranty provided. Use at your own risk. David Hamer, 2021 revision 10/4/2021 """ xP = yP = p4y = p5y = 0 def name(h): global nameSY if vs.PDescription == 'Tag': if notag == False: tagarray = vs.GetResourceTags(h) nameSY = (tagarray[0]) else: nameSY = '' if vs.PDescription == 'Symbol Name': nameSY = (vs.GetSDName(h)) if vs.PDescription == 'Record': nameSY = vs.GetRField(h,'Legend Record','Legend Text') def EvaluateSym(h): if vs.PExclude == True: if vs.GetName(vs.GetParent(h1)) != vs.PSymbolFolder: appendtolist(h) else: appendtolist(h) def appendtolist(h): if vs.PRecordName == '': hSEL.append(h) else: if vs.PRecordExclude == True: if vs.Eval(h, "(R IN ['"+vs.PRecordName+"'])") != True: hSEL.append(h) else: if vs.PRecordExclude == False: if vs.Eval(h, "(R IN ['"+vs.PRecordName+"'])") == True: hSEL.append(h) def DoIt(h5): global xP,yP,p4y,p5y,p3x,p3y,p2x,p1y h6 = h5 (p1,p2) = vs.GetBBox(h5) p1x=p1[0] p1y=p1[1] p2x=p2[0] p2y=p2[1] p3x = p2x-p1x p3y = p1y-p2y p5y = p4y+p1y-((p3y/2)+p1y) vs.Symbol(vs.GetSDName(h),xP+((p3x/2)-p2x),p4y-p1y,0) vs.TextOrigin(xP+vs.PControlPoint01X,p5y) vs.TextSize(vs.PTextsize) vs.TextVerticalAlign(3) vs.TextFont('Arial') name(h5) vs.CreateText(nameSY.upper()) p4y -= p3y + vs.PSymbolSpacing if vs.GetObject('Legend Record') == (): # Creates "Status and Phase" record if not present vs.NewField('Legend Record', 'Legend Text', '', 4, 0) hSEL = [] if vs.PSymbolFolder != '': if vs.PExclude == False: h1 = vs.FInFolder(vs.GetObject(vs.PSymbolFolder)) else: h1 =vs.FSymDef() else: h1 =vs.FSymDef() while h1 != []: EvaluateSym(h1) if vs.GetTypeN(h1) == 92: h2 = vs.FInGroup(h1) while h2 != []: if vs.GetName(vs.GetParent(h2)) != vs.PSymbolFolder: EvaluateSym(h2) h2 = vs.NextObj(h2) h1 = vs.NextObj(h1) for h in hSEL: if vs.GetTypeN(h) == 16: if vs.PDescription == 'Tag': tagarray = vs.GetResourceTags(h) if tagarray: notag = False DoIt(h) else: notag = True DoIt(h) else: DoIt(h) Symbol Legend.vso Quote Link to comment
The Hamma Posted October 6, 2021 Author Share Posted October 6, 2021 (edited) I simplified the script to the following. It appears to be something with it being a point object plugin tool and not when it is run as a simple script as it works as a script but not as a plugin object. To my knowledge it appears to only be an issue with tag objects. h1 =vs.FSymDef() while h1 != []: vs.Symbol(vs.GetSDName(h1),0,0,0) if vs.GetTypeN(h1) == 92: h2 = vs.FInGroup(h1) while h2 != []: if vs.GetTypeN(h2) == 16: vs.Symbol(vs.GetSDName(h2),0,0,0) h2 = vs.NextObj(h2) h1 = vs.NextObj(h1) Edited October 6, 2021 by The Hamma Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.