So we have some simply iLogic code that generates descriptions for some of our parts, but there are a few that we need to show in another "unit". I tried to leave the description generic and then to "check" the export parameter in Parameters and to then format those specific one to their units of choice, but we can't make it work.... IV 2015 doesn't seem to like mixing the format parameter and illogic working together?
Other than actually doing the math within the iLogic code, is there not a snipet that allows a unit convert?
Solved! Go to Solution.
So we have some simply iLogic code that generates descriptions for some of our parts, but there are a few that we need to show in another "unit". I tried to leave the description generic and then to "check" the export parameter in Parameters and to then format those specific one to their units of choice, but we can't make it work.... IV 2015 doesn't seem to like mixing the format parameter and illogic working together?
Other than actually doing the math within the iLogic code, is there not a snipet that allows a unit convert?
Solved! Go to Solution.
Solved by MechMachineMan. Go to Solution.
What problem are you having with it specifically? I have at least 15 different template files that use iLogic to take measurements of the part extents, write them to a parameter in inches, and then use the Custom Property Format settings to ft-in format. We've been using some version of this same setup since at least Inventor 2013. We've never really had any trouble out of it.
What problem are you having with it specifically? I have at least 15 different template files that use iLogic to take measurements of the part extents, write them to a parameter in inches, and then use the Custom Property Format settings to ft-in format. We've been using some version of this same setup since at least Inventor 2013. We've never really had any trouble out of it.
okay, there is a dude here who has existing templates set up that have all descriptions written in iLogic, for what we do those dimensions have to be shown in (ft / in). I then showed him how to do the same thing with the <> in the description field and even how to "format" the outcome ... (how I've been doing it for years as well), but instead of redoing all the descriptions in the iproperties using the "pacman symbols" we used his iLogic code for the descriptions and then checked the "export" box for the parameters we needed to format.... problem is the units are not re-formatting...
okay, there is a dude here who has existing templates set up that have all descriptions written in iLogic, for what we do those dimensions have to be shown in (ft / in). I then showed him how to do the same thing with the <> in the description field and even how to "format" the outcome ... (how I've been doing it for years as well), but instead of redoing all the descriptions in the iproperties using the "pacman symbols" we used his iLogic code for the descriptions and then checked the "export" box for the parameters we needed to format.... problem is the units are not re-formatting...
Either I'm completely misunderstanding your explanation, or you're somewhat misunderstanding the way the Custom Property Format actually works. My explanation here assumes the second - if it doesn't make sense, then maybe the first was true .
When you Export a Parameter and use Custom Property Format, it creates a Custom iProperty with the same value as the Parameter, formatted according to the Custom Property Format settings.
When you use the "pacman symbols" brackets in your Description, such as "SHAFT-<DIA> X <LENGTH>", what you are actually telling it to do is embed those Custom iProperty values into the Description.
If Dude's iLogic code just programmatically writes a string of text to the Description property that includes the Parameter values, then your Custom Property Format settings aren't even being used. Not because something in Inventor isn't working properly, but because the code just isn't telling it to look in the right place to see the format. The name "Custom Property Format" is literal - you're formatting the Custom iProperty, not the Parameter itself.
There are two ways I can see to make this work:
Either I'm completely misunderstanding your explanation, or you're somewhat misunderstanding the way the Custom Property Format actually works. My explanation here assumes the second - if it doesn't make sense, then maybe the first was true .
When you Export a Parameter and use Custom Property Format, it creates a Custom iProperty with the same value as the Parameter, formatted according to the Custom Property Format settings.
When you use the "pacman symbols" brackets in your Description, such as "SHAFT-<DIA> X <LENGTH>", what you are actually telling it to do is embed those Custom iProperty values into the Description.
If Dude's iLogic code just programmatically writes a string of text to the Description property that includes the Parameter values, then your Custom Property Format settings aren't even being used. Not because something in Inventor isn't working properly, but because the code just isn't telling it to look in the right place to see the format. The name "Custom Property Format" is literal - you're formatting the Custom iProperty, not the Parameter itself.
There are two ways I can see to make this work:
The iLogic code WILL NOT pull the "formatted" version from the parameter window. That formatting is exclusive to the "pacmans".
Take an example of a parameter named 'someparam' with an input "value" of "1 + .25 in", exposed, formatted to fraction WITH unit string.
Parameter.Param("someparam").Value pulls the decimal value in database units (the value converted to cms).
- In this case, "3.175" is the return value.
Parameter.Param("someparam").Expression pulls 'expression' as it appears in the input box.
- In this case, "1 in + 0.25 in" is the return value.
What you need to do for an "easy" fix for formatting is to get him to change his code from
iProperties.Value("Project", "Part Number") = "Size " & Parameter.Param("someparam").Value
to an expression form (with an "=" sign at the front, and using the pacman parameter name):
iProperties.Value("Project", "Part Number") = "=" & "Size " & "<someparam>"
OR
iProperties.Value("Project", "Part Number") = "=" & "Size <someparam>"
OR
iProperties.Value("Project", "Part Number") = "=Size <someparam>"
so then it will utilize the formatting as done in the parameter window..
Otherwise, he can custom format the value in the code and just assign it as a static value, but that's more complicated.
The iLogic code WILL NOT pull the "formatted" version from the parameter window. That formatting is exclusive to the "pacmans".
Take an example of a parameter named 'someparam' with an input "value" of "1 + .25 in", exposed, formatted to fraction WITH unit string.
Parameter.Param("someparam").Value pulls the decimal value in database units (the value converted to cms).
- In this case, "3.175" is the return value.
Parameter.Param("someparam").Expression pulls 'expression' as it appears in the input box.
- In this case, "1 in + 0.25 in" is the return value.
What you need to do for an "easy" fix for formatting is to get him to change his code from
iProperties.Value("Project", "Part Number") = "Size " & Parameter.Param("someparam").Value
to an expression form (with an "=" sign at the front, and using the pacman parameter name):
iProperties.Value("Project", "Part Number") = "=" & "Size " & "<someparam>"
OR
iProperties.Value("Project", "Part Number") = "=" & "Size <someparam>"
OR
iProperties.Value("Project", "Part Number") = "=Size <someparam>"
so then it will utilize the formatting as done in the parameter window..
Otherwise, he can custom format the value in the code and just assign it as a static value, but that's more complicated.
Hi @chris,
Here is one method of doing this:
Note too that there is a forum dedicated to programming questions of this type:
Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Hi @chris,
Here is one method of doing this:
Note too that there is a forum dedicated to programming questions of this type:
Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
so I am /have been doing the parameters method < >, but now I can't seem to get everything typed in... is there a way to "over-ride" the default text length (256 characters) within the iproperties?
so I am /have been doing the parameters method < >, but now I can't seem to get everything typed in... is there a way to "over-ride" the default text length (256 characters) within the iproperties?
@chris, your pictures confirm that you're doing exactly what I thought you were. Either of the proposed fixes from my previous post can potentially work for you.
The key thing you need to understand, as mentioned in my previous post, is that the Custom Property Format settings don't get applied to the Parameter at all. They get applied to the Custom iProperty that is created by exporting the Parameter. As written, your code and format settings are doing exactly what you are telling them to do. The problem is that they're being told to do the wrong thing.
@MechMachineMan's proposed fix is a third option whose logic falls somewhere between my two suggestions. It uses embedded property expressions, but uses iLogic code to write them for you.
In my opinion, by using iLogic you're somewhat overcomplicating this. If what you show in your post is the real code, and not just a simplified example, then the iLogic isn't doing anything for you that a simple iProperty expression wouldn't do. Your code can be fixed, as mentioned, in multiple possible ways. But the easiest fix may be to not use it at all.
@chris, your pictures confirm that you're doing exactly what I thought you were. Either of the proposed fixes from my previous post can potentially work for you.
The key thing you need to understand, as mentioned in my previous post, is that the Custom Property Format settings don't get applied to the Parameter at all. They get applied to the Custom iProperty that is created by exporting the Parameter. As written, your code and format settings are doing exactly what you are telling them to do. The problem is that they're being told to do the wrong thing.
@MechMachineMan's proposed fix is a third option whose logic falls somewhere between my two suggestions. It uses embedded property expressions, but uses iLogic code to write them for you.
In my opinion, by using iLogic you're somewhat overcomplicating this. If what you show in your post is the real code, and not just a simplified example, then the iLogic isn't doing anything for you that a simple iProperty expression wouldn't do. Your code can be fixed, as mentioned, in multiple possible ways. But the easiest fix may be to not use it at all.
the fix was it was allowing us to write out the description past 256 characters... because doing the iproperties method, (again, which I've always done), won't let me write everything out.... it's stops typing before I am finished typing.
=BEND, 5D, 90 DEG., <Elbow_OD>" x OD x <Elbow_WT>" WT, W/ <Elbow_Tangent_01>" x <Elbow_Tangent_02>" TAN, <Elbow_Radius>" RAD., (STOPS HERE)
what I need to type
=BEND, 5D, 90 DEG., <Elbow_OD>" x OD x <Elbow_WT>" WT, W/ <Elbow_Tangent_01>" x <Elbow_Tangent_02>" TAN, <Elbow_Radius>" RAD., API 5l X70
the fix was it was allowing us to write out the description past 256 characters... because doing the iproperties method, (again, which I've always done), won't let me write everything out.... it's stops typing before I am finished typing.
=BEND, 5D, 90 DEG., <Elbow_OD>" x OD x <Elbow_WT>" WT, W/ <Elbow_Tangent_01>" x <Elbow_Tangent_02>" TAN, <Elbow_Radius>" RAD., (STOPS HERE)
what I need to type
=BEND, 5D, 90 DEG., <Elbow_OD>" x OD x <Elbow_WT>" WT, W/ <Elbow_Tangent_01>" x <Elbow_Tangent_02>" TAN, <Elbow_Radius>" RAD., API 5l X70
Without the iLogic you're actually only getting 126 characters.
In this more complex situation, using iLogic does make a lot of sense. However, you might want to consider stepping back to my #2 proposed option from earlier.
The expression that is being written here is longer than its results would be. For example, in the expression <Elbow_OD> takes up considerably more characters than the result, which may be as little as two characters (ex. 1"). So if the code pulls the text string from the Custom iProperty instead of writing the entire expression, the result that gets fed back to the Description field will be shorter.
For simplicity, going back to your bar example from earlier, the code could be something like:
ODProp = iProperties.Value("Custom", "OD") LENGTHProp = iProperties.Value("Custom", "LENGTH") iProperties.Value("Project", "Description") = "BAR, ROUND, " & ODProp & " x " & LENGTHProp & " LG."
In this example, the iProperty Expression would be the following, which includes 32 characters:
=BAR, ROUND, <OD> X <LENGTH> LG.
The Description pushed out from the iLogic code would be the following, which includes 28 characters:
BAR, ROUND, 1” X 3 1/16” LG.
This example only shaves off 4 characters. However, your more realistic elbow example has both longer parameter names and more of them, so the reduction in length would probably be more noticeable.
Without the iLogic you're actually only getting 126 characters.
In this more complex situation, using iLogic does make a lot of sense. However, you might want to consider stepping back to my #2 proposed option from earlier.
The expression that is being written here is longer than its results would be. For example, in the expression <Elbow_OD> takes up considerably more characters than the result, which may be as little as two characters (ex. 1"). So if the code pulls the text string from the Custom iProperty instead of writing the entire expression, the result that gets fed back to the Description field will be shorter.
For simplicity, going back to your bar example from earlier, the code could be something like:
ODProp = iProperties.Value("Custom", "OD") LENGTHProp = iProperties.Value("Custom", "LENGTH") iProperties.Value("Project", "Description") = "BAR, ROUND, " & ODProp & " x " & LENGTHProp & " LG."
In this example, the iProperty Expression would be the following, which includes 32 characters:
=BAR, ROUND, <OD> X <LENGTH> LG.
The Description pushed out from the iLogic code would be the following, which includes 28 characters:
BAR, ROUND, 1” X 3 1/16” LG.
This example only shaves off 4 characters. However, your more realistic elbow example has both longer parameter names and more of them, so the reduction in length would probably be more noticeable.
is this a default limitation that can be changed in the registry.... like the default number of iPart rows? For now I can make my parameter names much shorter, lol
is this a default limitation that can be changed in the registry.... like the default number of iPart rows? For now I can make my parameter names much shorter, lol
Hello worked on it and found the answer to your query,works smoothly and solves your problem:
Dim doc As PartDocument doc = ThisApplication.ActiveDocument Dim unitsOfMeasure As UnitsOfMeasure unitsOfMeasure = doc.UnitsOfMeasure Dim lengthUnits As UnitsTypeEnum lengthUnits = UnitsTypeEnum.kMillimeterLengthUnits unitsOfMeasure.LengthUnits=lengthUnits
You can change the highlighted unit as per your requirement.
Hello worked on it and found the answer to your query,works smoothly and solves your problem:
Dim doc As PartDocument doc = ThisApplication.ActiveDocument Dim unitsOfMeasure As UnitsOfMeasure unitsOfMeasure = doc.UnitsOfMeasure Dim lengthUnits As UnitsTypeEnum lengthUnits = UnitsTypeEnum.kMillimeterLengthUnits unitsOfMeasure.LengthUnits=lengthUnits
You can change the highlighted unit as per your requirement.
Can't find what you're looking for? Ask the community or share your knowledge.