Cancel
Showing results for 
Search instead for 
Did you mean: 

Add Custom Symbol on new Drawing

Creator
Creator

Hey Folks,

i have a Question that i cannot seem to wrap my head around:

I have some Code that I start with a 3D model open and that generates me a new Drawing of that part (I am using Master-Model , so drawing and 3D are different entities). Next I want my code to add a Symbol on that Drawing . The tested Code is from a JOurnal and does exactly that, but when i execute it in the context of my big Macro, the Symbols are added to the Modelling (3D) Application of the Drafting instead of the Drafting itself even though i specifically run some code that switches to the Drafting Application!

Is there a way i can specify in the CustomSymbolBuilder that the Symbol has to be added to the Drafting View?

 

Here is the Code, that adds the Symbols:

Dim thatSession As Session = Session.GetSession()

 

Dim workPart As Part = thatSession.Parts.Work

Dim displayPart As Part = thatSession.Parts.Display

Dim I As Integer = 0

'switch to drafting View

Dim ThatUFSession As UFSession = UFSession.GetUFSession

ThatUFSession.Draw.SetDisplayState(2)

 

For I = 0 To Anzahl

Dim nullAnnotations_CustomSymbol As Annotations.CustomSymbol = Nothing

Dim draftingCustomSymbolBuilder1 As Annotations.DraftingCustomSymbolBuilder

draftingCustomSymbolBuilder1 = Workpart.Annotations.CustomSymbols.CreateDraftingCustomSymbolBuilder(nullAnnotations_CustomSymbol)

draftingCustomSymbolBuilder1.SelectSymbol("\\fsprmc01\CADHOME\Drawing_Standard\General\SYMBOLS\Key Characteristic Symbol.sym.prt")

Dim nullView As View = Nothing

Dim point1 As Point3d = New Point3d(345, 120 - I * 6, 0.0)

draftingCustomSymbolBuilder1.Origin.Origin.SetValue(Nothing, nullView, point1)

Dim nXObject1 As NXObject

Dim Txt() As Object = draftingCustomSymbolBuilder1.Texts().GetContents

draftingCustomSymbolBuilder1.SelectText(0)

draftingCustomSymbolBuilder1.ControlledNoteTitle = 2

draftingCustomSymbolBuilder1.SelectText(1)

draftingCustomSymbolBuilder1.ControlledNoteTitle = I + 2

nXObject1 = draftingCustomSymbolBuilder1.Commit()

draftingCustomSymbolBuilder1.Destroy()

Next

End Function

 

 

Thanks a lot for your Help!

2 REPLIES

Re: Add Custom Symbol on new Drawing

Esteemed Contributor
Esteemed Contributor

I think you actually have to open the drawing, not just set the display state.

 

Record a journal where you start in modeling (e.g. TOP view), then open "sheet 1".

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Add Custom Symbol on new Drawing

Creator
Creator

Worked like a Charm, thanks Ken!

Best Regards

Franz