iLogic-filename, parameters

iLogic-filename, parameters

pbartosinski
Enthusiast Enthusiast
2,315 Views
7 Replies
Message 1 of 8

iLogic-filename, parameters

pbartosinski
Enthusiast
Enthusiast

Hello

 

I have a small question. I made some simple assemblies (3 or 4 parts inside). Assembly and parts is parametric. I have iLogic in my .iam file wchich controls other .ipt's. Ok... works. But problem is when i copy all assembly and change filenames of the .ipt. It's obvious that there are some errors. Is there any solutions to keep in my iLogic rule proper filenames? (every time I have to edit my ilogic rule and change filenames)

 

Paweł

0 Likes
Accepted solutions (1)
2,316 Views
7 Replies
Replies (7)
Message 2 of 8

Sergio.D.Suárez
Mentor
Mentor

Hola, The suggestion is this, look at these examples, in the name of the detailed part in red

 

Component.Color("PartA:1")
iProperties.Value("part1:1", "Project", "Part Number")

 Do not write the name of the file, extract it as property, for example if you have a file of part, place this rule, it will return the name of the file, and in the routines you should use oName for example, to establish the name of the file.

For example, if you know the location in the model tree from assembly, you can specify the occurrence through the item, as in the following case executing this rule in an assembly

    Dim oDoc As AssemblyDocument
    oDoc = ThisApplication.ActiveDocument
    Dim oDef As AssemblyComponentDefinition
    oDef = oDoc.ComponentDefinition
    ' Get the top level occurrence of an assembly
    Dim oOcc As ComponentOccurrence
    oOcc = oDef.Occurrences.Item(2)'Firt component occurrence
	Dim oName As String
	oName = oOcc.Name
	MessageBox.Show(oName, "Title")

 Change the item number from 2 forward to identify the type of occurrence displayed by the model browser in the assembly. By identifying by item you can rename and you will not have problems. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 8

pbartosinski
Enthusiast
Enthusiast

hmmm.... i don't understand. I'll show example. In my assembly i have ilogic which contant line. It works but if i change name Flange_DIN.ipt to ex. Flange_DIN_1.ipt i have to edit my ilogic and change filename in Parameter section.

can you give me proper code how to avoid missing filename in this section below?

 

Parameter("Flange_DIN.ipt","DN") = DN_DIN

 

0 Likes
Message 4 of 8

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

What I was trying to tell you is that you should not put the name to identify a component in an assembly, because the name is what you are going to change

Parameter("Flange_DIN.ipt","DN") = DN_DIN

Then I leave you a code so you can identify the item that defines your component in the assembly, each item has a component

 

    Dim oDoc As AssemblyDocument
    oDoc = ThisApplication.ActiveDocument
    Dim oDef As AssemblyComponentDefinition
    oDef = oDoc.ComponentDefinition

	For i As Integer = 2 To oDef.Occurrences.Count
	    Dim oOcc As ComponentOccurrence = oDef.Occurrences.Item(i)
		MessageBox.Show("Item Number: " & i & vbCrLf & "Occurrence Name: " & oOcc.Name )
	Next

For instance, if for your part "Flange_DIN.ipt" you  find that it corresponds to item 3 you should place 

 

"Dim oFlangeDIN As ComponentOccurrence = oDef.Occurrences.Item(3)

 

Parameter(oFlangeDIN.name,"DN") = DN_DIN

 

I can not specify the item because I do not know how you have formed your assembly

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 5 of 8

pbartosinski
Enthusiast
Enthusiast

Works perfectly.

Thanks!!

0 Likes
Message 6 of 8

Anonymous
Not applicable

Hi,

 

I am having the same issue with my assembly renaming as you did. Until the names stay the same, the rules work, when I copy the assembly and change it's name and the name of its parts(the XX part changes), the rules do not work. Because  I am not a VB user and do not know hot to write  the statements, it would be very helpful if you could share your script that worked for you.

 

I tried to follow @Sergio.D.Suárez  instructions but I still get an error. 

 

Please help.

 

 

 

0 Likes
Message 7 of 8

johnsonshiue
Community Manager
Community Manager

Hi! Please share the files here. We have quite a few iLogic experts on the forum to help.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 8 of 8

bionorica2015
Enthusiast
Enthusiast
0 Likes