I am trying to automate a frame counter.
Frames that are negative are spaced differently than frames that are positive.
So in my example below, all negative frames are 24" on center, all positive frames are 7yrds (21ft) on center.
When I place a part, the Coordinate X gives a distance (CMF_COORD_X), I want iLogic to update my user parameter (X_BOM) to the correct Frame Number. (Decimals are okay)
Once I get this working, I would like to be able to change the 24" and 21ft numbers on the fly to match different projects.
Please let me know where I am messing up. Thank you in advance.
Kenny
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 7672 StartFragment: 314 EndFragment: 7640 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
'***** Start iLogic Rule "Convert X_Coord to Frame Spacing" ***** 'First 25 frames are on 24" spacing on center and at negative X distances SharedVariable ("Spacing") = 2 ft 'First 25 frames SharedVariable ("First_Frames") = 25 'All other frames are 3 yards apart SharedVariable ("Frames") = 21 ft 'All frames past the first 25 must add 50 ft SharedVariable ("Plus_First") = 50 ft 'Give error message if Parameter is missing Parameter.Quiet = False If CMF_COORD_X > 0 Parameter("X_BOM") = ("CMF_COORD_X"/2) '"2" to be replaced with "Spacing" Else Parameter("X_BOM") = ("CMF_COORD_X"/21)+Plus_First '"21" to be replaced with "Frames" End If '***** End iLogic Rule *****
Solved! Go to Solution.
Solved by MechMachineMan. Go to Solution.
Don't really understand what/ why you are trying to accomplish.
Also, your use of "SharedVariables" makes me wonder if there are other rules you are you going to be calling this rule from, or within this rule?
It is possible I am going about this the wrong way:
What I need: When I place a part in the assembly file, we use the X, Y, Z coordinates to locate the part on the BOM. Z is distance above a set level, Y is left or right of centerline. The X is distance along the frame supports (in feet). Currently we use an Excel table to convert the X to a Frame Number plus Inches past closest frame. I am trying to get iLogic to do it to create a User Parameter that I can link into my BOM.
The issue is the frame spacing changes depending on the build, so I wanted to be able to change those numbers easily at the assembly level (so I tried SharedVariables). Also, If an Item is located at a Negative X, the frame spacing is closer together than the frame spacing at a Positive X.
So I need an equation that checks if X>0 and finds the frame number at the short spacing or X<0 and it solves for the larger spacing. So a -4 X coordinate would be #-2 Frame. A 4 X coordinate would be #2 frame (or 2.3).
The frame spacing could be User Parameters, but I thought by making them SharedVariables it wouldn't require adding that info as parameters and would make changing the numbers in the Rule easier.
Thank you for giving this a look and trying to provide guidance!
Kenny
To question further, what about the part is being located by the BOM?
Do you constrain the frame members and pick "an arbitrary point" along a line to declare as the BOM Location?
Do you ground frame members and locate the origin of the occurrence using the same BOM values?
Is the excel file just to use the formula, or do you store information in there and drive models with it at all?
Where does the .3 come from in your example?
Starting thought are it would look something like this if using vb.net in a rule. It still needs coding to do the appropriate unit conversions, but an example like this could still help you along the way.
Sub Main()
'all values in feet. Dim spacing as decimal = 25
'First 25 frames Dim First_Frames as decimal = 25
'All other frames are 3 yards apart Dim Frames As decimal = 21
'All frames past the first 25 must add 50 ft Dim Plus_First As decimal = 50
Dim oDoc As Document = ThisDoc.Document
oParams = oDoc.ComponentDefinition.Parameters
If oParams("CMF_COORD_X").Value > 0 oParams("X_BOM").Value = oParams("CMF_COORD_X"/2).Value '"2" to be replaced with "Spacing" Else oParams("X_BOM").Value = oParams("CMF_COORD_X").Value /21) + Plus_First '"21" to be replaced with "Frames" End If
End Sub
Thank you for the help, Justin.
In ship design the hull frames are used as locational reference points. So an item being installed would be located at Frame 2 on the drawings. In our models, Frame 0 is at origin. So if the frames are 7 ft apart, Frame 2 would be at X= 14.00 (ft). Some ships have frames that go negative X, and those are usually spaced much closer together. The spacing changes on the different ships, so the numbers are not as important as the process. Once the process works, I can change the numbers per ship I am running the rule on. I need to check for Positive or Negative X, then have it divide that number by whatever the frame spacing is.
To your questions:
Each part is placed in the assembly, their X, Y, & Z coordinates are located in the BOM with their part/sub-assembly name. This works great except for the crafts with frame spacing that changes. People on ship need a way to change the X into Frames to be able to locate it.
The excel file is just the frame converter; no information drives the files. In the past we have just inserted it into the idw/dwg file.
Thank you for the starting point; I'll by out of office today and tomorrow, but will see if I can't move this forward after.
Best regards,
Kenny
Okay Team,
With the help of @MechMachineMan, @mcgyvr, @rjay75 and @Curtis_Waguespack I have found a much simpler approach that is working wonderfully.
Thank you all for helping me drill down. So what I have in the attached Rule is when x_dist is entered, it converts it based upon the number to a decimal frame count. Less than 0 is one frame spacing, greater than 50 ft is a different frame spacing, and the numbers in between are a third frame spacing.
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 4404 StartFragment: 314 EndFragment: 4372 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
Select Case (x_dist) Case <= 0: x_bom = (x_dist / 24) / 1 Case >50 ft: x_bom = ((x_dist - 50 ft) / 84 in) + 25 Case Else: x_bom = (x_dist / 24) / 1 End Select
All of this, is so on my BOM (Parts List) I can have each part report its nearest frame. The x_bom is linked to custom iProperties.
My question: I want now to convert the DECIMAL part of the answer to Inches. SO the answer would come back 26 + 12" (26 is the frame, the decimal is the inches). Any suggestions?
Thank you again to all for getting me this far!
Kenny
Hi @kennyj
What is the Unit of Decimal which you want to convert to Inches?
@Anonymous wrote:Okay Team,
With the help of @MechMachineMan, @mcgyvr, @rjay75 and @Curtis_Waguespack I have found a much simpler approach that is working wonderfully.
Thank you all for helping me drill down. So what I have in the attached Rule is when x_dist is entered, it converts it based upon the number to a decimal frame count. Less than 0 is one frame spacing, greater than 50 ft is a different frame spacing, and the numbers in between are a third frame spacing.
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 4404 StartFragment: 314 EndFragment: 4372 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
Select Case (x_dist) Case <= 0: x_bom = (x_dist / 24) / 1 Case >50 ft: x_bom = ((x_dist - 50 ft) / 84 in) + 25 Case Else: x_bom = (x_dist / 24) / 1 End Select
All of this, is so on my BOM (Parts List) I can have each part report its nearest frame. The x_bom is linked to custom iProperties.
My question: I want now to convert the DECIMAL part of the answer to Inches. SO the answer would come back 26 + 12" (26 is the frame, the decimal is the inches). Any suggestions?
Thank you again to all for getting me this far!
Kenny
Regards
B.Sharan Raj
Thank you @b_sharanraj,
Currently my answer is coming back as 25.142857 for an input of 51 feet. The 25 is correct; it is frame #25.
The .142857 is 12/84 (the frames are 7 ft apart, so every inch is 1/84).
So I want 25.142857 to result in 25 + 12". I don't know how to convert DISPLAY the decimal to the equivalent in inches. Sorry I'm not clear: The number is correct - I don't need to convert, I want to change the displayed output from 25.142857 to 25 + 12".
Thank you in advance for any suggestions or help.
Best regards,
Kenny
Here. Give this a whirl.
Sub Main() MsgBox(ConvertToKennyjFormat(25.142857)& vbLf & _ ConvertToKennyjFormat(25) & vbLf & _ ConvertToKennyjFormat(25.2235) & vbLf & _ ConvertToKennyjFormat(25.0)) End Sub Function ConvertToKennyjFormat(oNum) As String Dim SplitArr() As String SplitArr = Split(oNum, ".") If SplitArr.Length > 2 Then MsgBox("Weird number!") Return "False" ElseIf SplitArr.Length = 2 If SplitArr(1) <> 0 Then Return SplitArr(0) & " + " & Round(CDbl("." & SplitArr(1))*84) & Chr(34) Else Return SplitArr(0) End If Else Return SplitArr(0) End If End Function
Can't find what you're looking for? Ask the community or share your knowledge.