Cancel
Showing results for 
Search instead for 
Did you mean: 

NXOPEN Operation Starttime

Creator
Creator

Hello,

 

i really hope you can help me with this problem here. Now what i want is to set the starttime of a operation in VB.net. I can do it manually by moving the timeline in the editor (see picture).

 

But i want to do it in the Code. This is what i have right now. I get the current starttime of the operation via msgbox and it is correct. But i can not set the starttime to the value i want.

 

The starttime just does not change. Can you please help me. I would be really great.

 

Thank you very much.

 

11 REPLIES

Re: NXOPEN Operation Starttime

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Have you called the .Commit method on the builder object to apply the edits that you have made to the operation object?

Re: NXOPEN Operation Starttime

Creator
Creator

First of all, thank you very much for your answer!

 

No, right now i have not used the .Commit method. Could you please show me where and how to integrate it into my Code?

 

Thank you.

 

 

Re: NXOPEN Operation Starttime

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim ganttOperationObject1 As NXOpen.Mechatronics.GanttOperationObject = CType(workPart.GanttCollection.FindObject("GanttOperationObject["Operation_1"]"), NXOpen.Mechatronics.GanttOperationObject)
Dim ganttOperationBuilder1 As NXOpen.Mechatronics.GanttOperationBuilder
ganttOperationBuilder1 = workPart.GanttCollection.CreateGanttOperationBuilder(ganttOperationObject1)

MsgBox(ganttOperationBuilder1.StartTime)

'Problem is coming now! The Starttime does not change to 19
ganttOperationBuilder1.StartTime = 19.0

'change other values as desired

'the .Commit method will apply the changes you have made
ganttOperationObject1 = ganttOperationBuilder1.Commit

Re: NXOPEN Operation Starttime

Creator
Creator

Thank you, but executing this command brought the following error message:

Error in external library. See system log for details

File name: "Path..."

Function name: Main

Where can i find the system log?

 

Thank you

Re: NXOPEN Operation Starttime

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

If NX is still running, go to Help -> Log file.

 

If NX has crashed completely, check your temp folder for the most recent .syslog file.

Re: NXOPEN Operation Starttime

Creator
Creator

The Log File has a lot of information. But i think the main Information causing the error is this

 

NXOpen.NXException: Internal error: memory access violation
   at NXOpen.Builder.Commit()

Do you know how to solve this?

 

Thank you.

Re: NXOPEN Operation Starttime

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

I'm not sure what is causing the error.

 

In the code that I posted, the object returned by the builder is assigned back to the original object reference. Perhaps the internal functions don't like this and it should be assigned to a new reference. Also, the builder object should be destroyed when you are done with it.

 

If an error occurs, perhaps the displayed error message will help you track down the cause.

 

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim ganttOperationObject1 As NXOpen.Mechatronics.GanttOperationObject = CType(workPart.GanttCollection.FindObject("GanttOperationObject["Operation_1"]"), NXOpen.Mechatronics.GanttOperationObject)
Dim ganttOperationBuilder1 As NXOpen.Mechatronics.GanttOperationBuilder
ganttOperationBuilder1 = workPart.GanttCollection.CreateGanttOperationBuilder(ganttOperationObject1)

MsgBox(ganttOperationBuilder1.StartTime)

'Problem is coming now! The Starttime does not change to 19
ganttOperationBuilder1.StartTime = 19.0

'change other values as desired

dim newOp as NXOpen.Mechatronics.GanttOperationObject
Try
    'the .Commit method will apply the changes you have made
    newOp = ganttOperationBuilder1.Commit
Catch ex as nxexception
    'display error message
	msgbox(ex.message)
Catch ex as Exception
    'display error message
	msgbox(ex.message)
Finally
    ganttOperationBuilder1.Destroy
End Try

 

 

Edit:

Also, the code in the .FindObject method doesn't look right. If you are trying to concatenate strings, you will need to use the "&" or "+" operator. As it currently stands, there is a string:

"GanttOperationObject["

followed by something (a variable reference?)

Operation_1

followed by another string

"]"

 

The current form is not valid syntax. If .FindObject isn't throwing an error, it is probably returning a null object reference.

Re: NXOPEN Operation Starttime

Creator
Creator

Thank you for your answer.

 

I think the .FindObject method is working correctly right now. I always get the right starttimes for every Operation even if i have multiple operations working. So i think NX is finding the right Operations.

 

But no matter what i try, i always get the "Internal error: memory access violation"

 

ganttOperationObject1 = ganttOperationBuilder1.Commit()
Dim nXObject As NXOpen.NXObject
nXObject = ganttOperationBuilder1.Commit()
Dim newOp As NXOpen.Mechatronics.GanttOperationObject
newOp = ganttOperationBuilder1.Commit()

I really tried a lot. But it does not work.

 

Thank you.

 

Re: NXOPEN Operation Starttime

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Perhaps it is time to call GTAC.