need advice in macros
need advice in macros
(OP)
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
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





RE: need advice in macros
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.
Mark Benson
Aerodynamic Model Designer
RE: need advice in macros
Hi,
i didnt get what extracting edges for drafting mean..
Just giving a tip not a solution for your task
Session object is .NET reference where as UFsession object is UFUNC Open C wrappers reference
you need to instantiate these two to get hold on the current NX session and operate on the function calls
RE: need advice in macros
my code is
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.Drawings
Module Module1
Sub Main()
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
RE: need advice in macros
Hi,
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.
RE: need advice in macros
RE: need advice in macros
i need to turn on autoupdate in Sheetmetal flatpattern...
can not manage...
code:
Sub set_smd_pref
'sheet metal preferences setup
dim smd as UFSmd
dim fp_options() As UFSmd.FpPrefs
smd.AskFpPrefs(fp_options)
fp_options.auto_update = true
End Sub
RE: need advice in macros
Hi,
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")
End If
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
RE: need advice in macros
experience is forever thing! :)