Hello macro experts!
I need use UF_DRAW_extracted_edge to change current view style in drawing
could someone give the simple example...
I dont know when should use session when ufsesssion and what is difference...
thanks
if the function you want to use has UF at the start it needs a UFsession.
I think the syntax for that command would be
Ufsession.Draw.extracted_edge
That's just off the top of my head and needs to be checked.
Dim i, j As Integer
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim drtag As Tag()
Dim v_tag As Tag()
Dim numd As Integer
Dim numv As Integer
Dim PartName As String
ufs.Draw.AskDrawings(numd, drtag)
For i = 0 To numd - 1
ufs.Draw.AskViews(drtag(i), numv, v_tag)
Dim v_par As UFDraw.ViewPrfs
For j = 0 To numv - 1
v_par.extracted_edges = 1
ufs.Draw.SetViewDisplay(v_tag(j), v_par)
Next
Next
End Sub
End Module
it failed with error
NXOpen.NXException: Input is not a valid parameter.
at NXOpen.UF.UFDraw.SetViewDisplay(Tag view_tag, ViewPrfs& view_parms)
at NX.Module1.Main() in nx://root/Script:line 29
You have declared the structure for view preferences, but it needs to be initialized for all the values it has. you are supplying only the extracted edges input.
Try using this way....
For j = 0 To numv - 1
ufs.Draw.AskViewDisplay(v_tag(j), v_par)
v_par.extracted_edges = 1
ufs.Draw.SetViewDisplay(v_tag(j), v_par)
Next
Now the whole of the structure instance is poppulated with the default values..will get modified in the subsequent statement and then the update is driven.
Find the corrected code below with appropriate comments
Sub set_smd_pref()
Try
''' / Need to get the session object /
Dim UFS As UFSession = UFS.GetUFSession
''' / Do not access wrapper class objects directly
''' They cannot be instantiated, but only the shared
''' elements can be accessed /
'sheet metal preferences setup
'Dim smd As UFSmd
Dim fp_options(-1) As UFSmd.FpPrefs
UFS.Smd.AskFpPrefs(fp_options)
With fp_options(0)
MessageBox.Show("Existing auto update preferences value :" + .auto_update.ToString)
''' / Check the default value before overriding /
If Not (.auto_update) Then
fp_options(0).auto_update = True
MessageBox.Show("Value succesfully changed to TRUE")