NX9 - VB Code for Attributes (Hope you like a challenge)
NX9 - VB Code for Attributes (Hope you like a challenge)
(OP)
We have to add this note to a lot of different drawing sheets we work on...
-BUILD EVENT: xxxxxxxxx
-KCDS DESIGNATION: STD CARE UNLESS OTHERWISE NOTED
-PE DISPENSE FILE: xxxxxxx/xxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-BEADS FOLLOW PRODUCT FEATURES UNLESS OTHERWISE NOTED
-PULL OUT STA NO: N/A
(The info in place of the xxxxxx will change from file to file that we work on.)
1) It doesnt make sense to have someone type this out every time. So i figured to make it a part file of its own that a button will import. Makes it simple. Hit a button, the entire note appears.
2) My bosses dont want to make people have to go into each note and type out the different info on each sheet it is needed. So I thought of adding three attributes to the poperties of a file and have the notes connect to the attributes. Like adding <W@PAINT_CODE> in place of the xxxx and creating a poperty attribute for PAINT_CODE. Then it only needs to be typed out once and every time we add the note, it will automatically complete.
I have code that works for importing files. What I dont know how to do is write .vb code that before importing the part file, it will check to see if three specific attributes are available, and if not, it will promp someone to fill out the info and then automatically create the attributes for them. Then it will import the note's part file.
I am pretty sure I am making this confusing. I have a bad habit of that. lol
-BUILD EVENT: xxxxxxxxx
-KCDS DESIGNATION: STD CARE UNLESS OTHERWISE NOTED
-PE DISPENSE FILE: xxxxxxx/xxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-BEADS FOLLOW PRODUCT FEATURES UNLESS OTHERWISE NOTED
-PULL OUT STA NO: N/A
(The info in place of the xxxxxx will change from file to file that we work on.)
1) It doesnt make sense to have someone type this out every time. So i figured to make it a part file of its own that a button will import. Makes it simple. Hit a button, the entire note appears.
2) My bosses dont want to make people have to go into each note and type out the different info on each sheet it is needed. So I thought of adding three attributes to the poperties of a file and have the notes connect to the attributes. Like adding <W@PAINT_CODE> in place of the xxxx and creating a poperty attribute for PAINT_CODE. Then it only needs to be typed out once and every time we add the note, it will automatically complete.
I have code that works for importing files. What I dont know how to do is write .vb code that before importing the part file, it will check to see if three specific attributes are available, and if not, it will promp someone to fill out the info and then automatically create the attributes for them. Then it will import the note's part file.
I am pretty sure I am making this confusing. I have a bad habit of that. lol





RE: NX9 - VB Code for Attributes (Hope you like a challenge)
-Put the notes into a blank drawing file and make the relations
-"Import Part" on the desired part
- see if it worked (atributes must be already created or else i thing it will not be "linked")
i do some things like what you are trying to do here, i will try to help you
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
That was already my plan from what it sounds like. I have a folder where I keep part files that are nothing more than a note to be imported. In the above note, I want to place a bit of code (In place of the xxxx) so that it will read the attribute of whatever file I import that into.
My problem is creating the attribute to begin with. I know how to create attributes by going into File/Properties, but my boss does not want the inexperienced people having to do this right now. So I want to add VB code to the Import Note button I will make that will automatically create three attributes and prompt the user for the info for each attribute. Once they fill out the info and hit OK, it will finish creating the attributes then add the note.
Contrary to what I wrote before, my boss doesnt want it to look to see if the attributes are there already or not. He wants it to prompt them for the info each time they add the note in case they need to change the info.
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
BUILD_EVENT
PE_DISPENSE_FILE
PE_DISPENSE_FILE_REV
PE_DISPENSE_FILE_NAME
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
you can put the journal assigned to a buton or keybind, try and see if it works :)
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
I do appreciate all the work you are putting into helping me out. Unfortunately I am thinking this one may be waaayyyy over my head. lol
The only thing I really know about code is what I have learned here. I have gotten code from someone once and I have learned to manipulate it for similar tasks. When opening this file, I realize just how little I do know. I see there are several areas where I am supposed to add exception handling code. I looked it up and found it is also called exception error code. As to how to write the code for that or what it is for in any of these places in the code is beyond me. Heck, this is the first time I have seen a .DLX file and I have no idea what to do with that.
Either way, it is looking like doing this may be digging me much deeper into code than I am ready for. We should probably have to just teach people to add attributes manually. lol Even the bosses dont always get what they want. lol
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
the DLX its because im using Block Styler alonside with journaling (i think its correct to say this) im a bit noob on journaling aswell x)
u just need to put the dlx on the same folder as the .vb i already "programed" to your variables so you just need to run it.
first Test if it works: alt+F8 (i think the journal window will appear then browse the .vb file, select it and run it a box should appear (ive attached a print screen)
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
CODE
Public Sub New() Try theDlxFileName = "checkAttributes.dlx"edit and put the path of it ex if the files are on a folder called ATT on C:
CODE
Public Sub New() Try theDlxFileName = "c:\ATT\checkAttributes.dlx"try and tell-me if it worked
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
For a test, I added...
11111
22222
33333
44444
And when I hit OK, it went away but didnt do anything that I can tell. I am guessing you didnt expect it to because you need to direct me on more code changes.
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
if they are created it returns the value on it, if they are not created, it creates the atribute upon ok/apply
and u can change the values
do you want a window to appear after you press the OK/APPLY ?
isnt this what u want ? the user to press a buton and access those atributes ?
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
You have gone far and above
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
CODE
put it like this:
CODE
now it will work Tested on 9 :)
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
I have this following code to add a note. Which is actually just importing a part file. How would I go about putting these two together, so that when someone adds the note, it will automatically have them create the attributes as well? ..... If I play with it for a while I think I can figure it out, but if its not hard to do, if you could just tell me where to add your attribute code to it, it would save me a lot of time.
' NX 9.0.2.5
' Journal created by kschonmeier on Wed Nov 04 12:37:44 2015 Eastern Standard Time
'
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: File->Import->Part...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Import Part")
Dim partImporter1 As PartImporter
partImporter1 = workPart.ImportManager.CreatePartImporter()
partImporter1.FileName = "R:\hms_tools\NX9\Tooling\part\DISPENSE VISUAL AIDS\BUILD NOTE.prt"
partImporter1.Scale = 1.0
partImporter1.CreateNamedGroup = False
partImporter1.ImportViews = False
partImporter1.ImportCamObjects = False
partImporter1.LayerOption = PartImporter.LayerOptionType.Work
partImporter1.DestinationCoordinateSystemSpecification = PartImporter.DestinationCoordinateSystemSpecificationType.Work
Dim element1 As Matrix3x3
element1.Xx = 1.0
element1.Xy = 0.0
element1.Xz = 0.0
element1.Yx = 0.0
element1.Yy = 1.0
element1.Yz = 0.0
element1.Zx = 0.0
element1.Zy = 0.0
element1.Zz = 1.0
Dim nXMatrix1 As NXMatrix
nXMatrix1 = workPart.NXMatrices.Create(element1)
partImporter1.DestinationCoordinateSystem = nXMatrix1
Dim destinationPoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)
partImporter1.DestinationPoint = destinationPoint1
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import Part Commit")
Dim nXObject1 As NXObject
nXObject1 = partImporter1.Commit()
theSession.DeleteUndoMark(markId2, Nothing)
partImporter1.Destroy()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
u have something like:
CODE
Public Shared Sub Main() Dim thecheckAttributes As checkAttributes = Nothingput like this:
CODE
Public Shared Sub Main() Dim partImporter1 As PartImporter partImporter1 = workPart.ImportManager.CreatePartImporter() partImporter1.FileName = "R:\hms_tools\NX9\Tooling\part\DISPENSE VISUAL AIDS\BUILD NOTE.prt" partImporter1.Scale = 1.0 partImporter1.CreateNamedGroup = False partImporter1.ImportViews = False partImporter1.ImportCamObjects = False partImporter1.LayerOption = PartImporter.LayerOptionType.Work partImporter1.DestinationCoordinateSystemSpecification = PartImporter.DestinationCoordinateSystemSpecificationType.Work Dim element1 As Matrix3x3 element1.Xx = 1.0 element1.Xy = 0.0 element1.Xz = 0.0 element1.Yx = 0.0 element1.Yy = 1.0 element1.Yz = 0.0 element1.Zx = 0.0 element1.Zy = 0.0 element1.Zz = 1.0 Dim nXMatrix1 As NXMatrix nXMatrix1 = workPart.NXMatrices.Create(element1) partImporter1.DestinationCoordinateSystem = nXMatrix1 Dim destinationPoint1 As Point3d = New Point3d(0.0, 0.0, 0.0) partImporter1.DestinationPoint = destinationPoint1 Dim markId2 As Session.UndoMarkId markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import Part Commit") Dim nXObject1 As NXObject nXObject1 = partImporter1.Commit() theSession.DeleteUndoMark(markId2, Nothing) partImporter1.Destroy() Dim thecheckAttributes As checkAttributes = Nothingsee if it works
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
the DLX its like Style Sheet
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
i will try to make a buton fo your import and call the function thru there, i will send it on monday
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
I do appreciate it all. Hope you have a great weekend.
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
(dont forget to put the path to the DLX, and the PRT)
CODE
CODE
to import the prt press the "no title" button
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
Sorry I didnt reply yesterday. Bosses were pushing for specific things to get done yesterday and I never even had a chance.
So I tried these files. When I played back the VB code file, it brought up the attribute box and I filled that out and hit OK. It disappeared and then that was it. No note ever appeared. For now I have set up separate buttons that work fine. One button to add the attributes and one to bring in the note's .prt file.
I matched the code from the working vb file that brings in the note to the same section in your new vb file. They seem to be exactly the same, so to test it, I coppied the one to the other and tried it. Same results. No note prt file was imported.
Not understanding what it all means enough, I wonder about the location of the .dlx file still. There is a section in the code stating where the dlx file needs to be and I asked our IT person where UG launches from. But I question if it is possible they gave me the wrong location and that is the problem? Is there a specific file that this DLX file should be in the same folder with?
I will be honest with you. If it is not difficult to figure out what is wrong, that would be great to have it working with one button. But if it is something you would have to study and spend much time on, the two button way of things works okay. You have helped me immensely. The attribute code alone is awesome. I do not wish to put you through a hassle just to combine two buttons if the two are working.
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
NX8.5 - NX9 - NX 10 - NX11
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
RE: NX9 - VB Code for Attributes (Hope you like a challenge)
i dont mind taking the challenge because i want to be better @ journaling and understand it, so this is perfect :) thank you
NX8.5 - NX9 - NX 10 - NX11