How to use iLogic to return a filename of a derived part?

How to use iLogic to return a filename of a derived part?

Anonymous
Not applicable
1,333 Views
9 Replies
Message 1 of 10

How to use iLogic to return a filename of a derived part?

Anonymous
Not applicable

I'm using a derive in a model to make a design (picture 1).

For the moment I have some troubles with using iLogic rule.

First thing:

I want to get the filename without filepath (I prefer also without extension) of this derived part by using iLogic rule. 

The next thing:

I want to have this filename in an User parameter.

All I have found is:

modelFileNamewithoutextension = IO.Path.GetFileNameWithoutExtension(modelFullFileName) 

But this is the filename of the model... Who can help me please?

picture 1picture 1

 

0 Likes
Accepted solutions (3)
1,334 Views
9 Replies
Replies (9)
Message 2 of 10

Thomas_Savage
Advisor
Advisor
Accepted solution

Hello @Anonymous 

 

This would be better posted in the Inventor Customization forum.

 

I have asked for this to be moved for you.

 

I hope you get a solution to your problem there.

 

Thomas.



Thomas Savage

Design Engineer


0 Likes
Message 3 of 10

Sergio.D.Suárez
Mentor
Mentor

hi, try this ilogic code greetings

Dim refdoc As Document = ThisDoc.Document.ReferencedDocuments.Item(1)

Dim onext As String = refdoc.DisplayName
Dim offext As String = IO.Path.GetFileNameWithoutExtension(onext) 

MessageBox.Show(onext, "with extension")
MessageBox.Show(offext, "without extension")

 


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 4 of 10

Anonymous
Not applicable

Hi, thanks.

Running this rule gives me the same result. Both is without ext.

0 Likes
Message 5 of 10

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

hi, if it's good for you, you can mark my answer as a solution, greetings


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

0 Likes
Message 6 of 10

Anonymous
Not applicable

One thing is solved.

But can you also help me with the other thing:

How can I get this filename into an User Parameter?

0 Likes
Message 7 of 10

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

You must first create user parameters, such as text.
then you must load those parameters to the rule, here is an example.

 

 

1.jpg2.jpg

 

Dim refdoc As Document = ThisDoc.Document.ReferencedDocuments.Item(1)

Dim onext As String = refdoc.DisplayName
Dim offext As String = IO.Path.GetFileNameWithoutExtension(onext) 

MessageBox.Show(onext, "with extension")
MessageBox.Show(offext, "without extension")


Name1 = onext
Name2 = offext

Parameter.UpdateAfterChange = True
iLogicVb.UpdateWhenDone = True

 


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

0 Likes
Message 8 of 10

Anonymous
Not applicable

Thank you very much!

It's solved for me.

Greetings Jan

Message 9 of 10

raphael.widmann5DUKP
Participant
Participant

Edit: replayd not to Jan but to Sergio...

0 Likes
Message 10 of 10

raphael.widmann5DUKP
Participant
Participant

Hello guys,

as Jan mentioned, the result of both (onext/offext) is the same. In my case, I have the following result:

First the code:

 

 

 

'Ermitteln der Materialangabe aus Unterkomponente

	'Auslesen der Basiskomponente
	Dim basepart As Document = ThisDoc.Document.ReferencedDocuments(1)
	basepart_name = basepart.DisplayName
	basepart_filename = IO.Path.GetFileName(basepart_name)
	
	'Auslesen der Materialangabe 
	mat_variant = Parameter.Value("GER_BEL_CAD10063859.ipt", "Materialvariante")

	'Zuweisen der Materialangabe zu Material
	iProperties.Material = mat_variant

'Testausgabe
MessageBox.Show(mat_variant.ToString & " - " & basepart_filename, "TEST")

 

 

 

 

My MessageBox shows the following:

raphaelwidmann5DUKP_0-1664435773856.png

 

So you wont get the filename with it, but the displayname at the browser (maybe on in most cases this is the same, but not on my config of the modelbrwoser).

raphaelwidmann5DUKP_1-1664435912706.png

 

What I exactly need is this:

raphaelwidmann5DUKP_2-1664435981744.png

raphaelwidmann5DUKP_3-1664436049664.png


I've tried different things, ending up with this:

 

oDoc = ThisApplication.ActiveDocument
If oDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 0
Dim oDerComp As DerivedPartComponent = oDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents(1)
Dim oDerDef As DerivedPartDefinition = oDerComp.Definition.Name

 


But this is also giving just hte name at the modelbrowser...

 


Do you have any Ideas, how to get the filename?

 

Thanks very much in advance!

 

BR
Raphael

0 Likes