Thickness to Stock Material with External RUle

Thickness to Stock Material with External RUle

vkulikajevas
Advocate Advocate
477 Views
2 Replies
Message 1 of 3

Thickness to Stock Material with External RUle

vkulikajevas
Advocate
Advocate

I have a part opened, and I need Thickness parameter automatically to be imported to Stock Number.

This code works when rule exists in a part. But when there is a new part without this rule, and Rule runs externally, Stock Number does not receive Thickness parameter. Is there a way to overcome this? Maybe this syntax line is not enough for External Rule? 

 

iProperties.Value("Project", "Stock Number") = "t = " & Thickness & " mm"

 

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

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, In your part rule when you place "Thickness" it looks blue. This is because it makes an internal link to the parameter, it is a kind of programming shortcut.
It is for this reason that I previously shared an example that I now share again that is a way of accessing the thickness from the properties of the document, regardless of the language in which you work. You just have to keep in mind that you use the internal inventor unit that is the "cm", so place the multiplication factor of * 10 to achieve the mm.

 

Dim doc As Document = ThisDoc.Document

Try
Dim oThick As Double = Round(doc.componentdefinition.thickness.value*10, 2)

iProperties.Value("Project", "Stock Number") = "t = " & oThick & " mm"

Catch
iProperties.Value("Project", "Stock Number") = ""
End Try

 Try to execute this rule as an external rule.
I hope this helps with your problem. 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

0 Likes
Message 3 of 3

vkulikajevas
Advocate
Advocate

You were totally right! Works very well. I should have tested this method before more carefully!

0 Likes