Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 532

put a drawing view name to prompted entry symbol

$
0
0

By Xiaodong Liang

Question:
The user wants to pick a drawing view, and change the result string of prmpted entry text in all sketched symbols, with the view name as the prefix.

Solution:
The prmpted entry text is defined in SketchedSymbolDefinition. And the final SkecthedSymbol provides the method SetPromptResultText which can set the result string of the specific prmpted entry text. The code below asks the user to pick one drawing view, find the specific prmpted entry text, and change its result string. It assumes the SketchedSymbolDefinition is named “MySymbol”and the prmpted entry text is named “MY_PROMPT”in the SketchedSymbolDefinition.

Actually, this workflow also applies TitleBlock, Border etc.

Dimdoc as DrawingDocument

    doc=ThisApplication.ActiveDocument

   

       

    DimoObjAsObject     

    oObj=ThisApplication.CommandManager.

                Pick(SelectionFilterEnum.kDrawingViewFilter,"Select a view:")

   

   

    IfoObjIs Nothing Then

   

    Else

         DimviewNameAsString=oObj.Name

        

         DimoNewResultText

         oNewResultText=viewName+"other description"

                 

         DimoPromptText  AsTextBox

        

        

         ' assume the name of sketched symbol definition is

         '"MySymbol"

         DimoSSDAsSketchedSymbolDefinition

         oSSD=doc.SketchedSymbolDefinitions("MySymbol")

        

        

         '' search the prompt textbox in definition

         DimoEachTextAsTextBox

         DimI

         ForI=1TooSSD.Sketch.TextBoxes.Count

          oEachText=oSSD.Sketch.TextBoxes(I)

          If(oEachText.Text="MY_PROMPT")Then

            ' found the prompt text we want to copy

              oPromptText=oEachText

            ExitFor

          EndIf

        NextI

       

        'change the result text of the SketchedSymbol

        DimoSSAsSketchedSymbol

        ForEachoSSIndoc.ActiveSheet.SketchedSymbols

           IfoSS.Definition.Name="MySymbol"Then

              MsgBox(oNewResultText)

               oSS.SetPromptResultText(oEachText,oNewResultText)

           EndIf

        Next

   

    EndIf

 

 

image


Viewing all articles
Browse latest Browse all 532

Trending Articles