Problem with ilogic copy design

Problem with ilogic copy design

Cadkunde.nl
Collaborator Collaborator
590 Views
3 Replies
Message 1 of 4

Problem with ilogic copy design

Cadkunde.nl
Collaborator
Collaborator

Hello,

 

I'm trying to place configurable models using "Place iLogic Component" functionality.

This works pretty good, but I want to kill the 2nd instance under the cursor after placing

 

 

Attached i have added 2 files.

In testassy2.iam I have 3 rules.

 

Script: normal - shows a working placement of testpart.ipt in the assembly using ilogic copy design.

But got the problem mentioned above, user has to cancel 2nd instance.

 

I managed to kill the 2nd instance with rule: "test with event no removehandler".

 

From a user point of view: this does exactly what I want. 2nd instance under cursor is killed and form still functions normally.

Problem is that this rule remains active with the event on new occurrence.

When I add a 2nd occurrence, there are 2 rules responding to event.

When adding 3th i get 3 rules, etc etc. So this is not good.

 

Then i got rule: "test with event"

This gives weird errors. The object cannot be saved, I get errors making chances in the form, or closing the form.

 

Hopefully someone here can give me insight what is happening and how to solve it

 

 

0 Likes
Accepted solutions (1)
591 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor
Accepted solution

Hi @Cadkunde.nl . 

Nice little project you have going on there. I had worked a little before with the place ilogic place command but  stopped short of trying to control it's functionality. I was able to get this to work for you with one little change which came about after lots of head scratching ( first time working with events). Just one small change  from "EventTimingEnum.kAfter" to "EventTimingEnum.kBefore"

 

Class ThisRule
	Private oAsmEvents As Inventor.AssemblyEvents
	Sub Main()
		oAsmEvents = ThisApplication.AssemblyEvents
		
		AddHandler oAsmEvents.OnNewOccurrence, AddressOf oAsmEvents_OnNewOccurrence

		SharedVariable("AssemblyName") = ThisDoc.Document.FullFileName

		Dim cm As CommandManager
		cm = ThisApplication.CommandManager
		cm.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, "C:\Users\testpart.ipt")

		cm.ControlDefinitions("iLogic.PlaceComponent").Execute

	End Sub

	Public Sub oAsmEvents_OnNewOccurrence(oAsmDoc As AssemblyDocument, oOcc As ComponentOccurrence, oTiming As Inventor.EventTimingEnum, oContext As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum)
		If oTiming = EventTimingEnum.kBefore Then

			Dim cm As CommandManager
			cm = ThisApplication.CommandManager
			cm.ControlDefinitions.Item(ThisDoc.Document.DefaultCommand).Execute
			RemoveHandler oAsmEvents.OnNewOccurrence, AddressOf oAsmEvents_OnNewOccurrence
		
		End If
	End Sub
End Class

 I also attempted to control the file naming and occurrence naming but I wasn't successful. That will still need to be done as a different operation. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 4

Cadkunde.nl
Collaborator
Collaborator

Thanks, I will look in to it tomorrow at work. Haven't tried "kBefore".

 

With iLogic copy design the files are renamed automatically, and it uses Vault Pro naming scheme.

Also iLogic copy design copies only the files found in the same folder + subfolders and reusing all other components.

0 Likes
Message 4 of 4

Cadkunde.nl
Collaborator
Collaborator

That did the trick.

Perfect timing, no weirdness afterwards.

 

Many thanks

0 Likes