- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi forum, I have one part full constraint, I would like to keep the internal and externa Ø as a default parameter and then create another parameter wall thickness so can have the option to toggle between the internal Ø and wall the thickness.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm not 100% sure I understand what you are wanting. Are you planning on using a Form to allow the user to specify parameter values? After looking at your model sketch and parameters, I'm guessing you want to change which 2 (out of 3) dimensions have 'driving' control, and which 1 will be 'driven'? If this is the case, you will need to access the sketch, enter into 'edit mode', find & identify those 3 dimensional constraints, then toggle their properties between 'driving' and 'driven' as needed, all though an iLogic rule. This is possible, but might be challenging/complicated to achieve. And if anything happens to those sketch dimensions (like deleted), it will leave your rule useless. Does that sound like the process you were looking for?
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
For some reason, it's not letting me toggle the Driven property of those dimension constraints between True & False. It seems like it will let me toggle one, but not the other. I know you have to do it in the right order, or it will throw an error, because you can't have two driving dimension trying to control the same fully constrained sketch entity, so I'm being careful with that, but still getting an error. I am also aware that when you toggle a sketch dimension between 'driving' and 'driven' it also switches the parameter that the dimension represents between being a regular model parameter and being a reference parameter. Maybe this has something to do with it. For some reason it is thinking that a dimension (the ID dimension) is 'Driven', when it's not, and is trying to set it to 'driving', which I believe is where the error is happening. I'm not sure how to deal with that situation, since it seems to be a 'Bug'.
Anyways, here is the iLogic rule I created for your provided part document. I believe it is finding the dimensions OK, just not toggling their 'Driven' property correctly. I had a ton of Msgbox's in there before trying to track down where the error is happening, and why, but have removed most of them, leaving the Try...Catch blocks in there for now. I know where the error is happening (mentioned above), just not sure how to fix it.
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oSketch As PlanarSketch
Try
oSketch = oPDef.Sketches.Item("SK BS 4825-3")
Catch
MsgBox("Couldn't find that sketch. Exiting Rule.", , "")
Exit Sub
End Try
oPDoc.Update2(True)
oSketch.Edit
'identify the 3 dimensions
Dim oID, oOD, oThickness As DimensionConstraint
For Each oDC As DimensionConstraint In oSketch.DimensionConstraints
If oDC.Parameter.Name = "BS4825:1" Then
oID = oDC
MsgBox("oID was found. It's value is " & oID.Parameter.Value.ToString,,"")
ElseIf oDC.Parameter.Name = "BS4825:2" Then
oOD = oDC 'we're leaving this one alone for now
MsgBox("oOD was found. It's value is " & oOD.Parameter.Value.ToString,,"")
ElseIf oDC.Parameter.Name = "d109" Then
oThickness = oDC
MsgBox("oThickness was found. It's value is " & oThickness.Parameter.Value.ToString,,"")
End If
Next
'make sure we've got them
If IsNothing(oID) Or IsNothing(oOD) Or IsNothing(oThickness) Then Exit Sub
'now try to toggle them
'toggling needs to happen in correct order, or it will throw an error
If oID.Driven = True And oThickness.Driven = False Then
MsgBox("oID.Diven = True And oThickness.Driven = False")
Try
oID.Driven = False
MsgBox("Just toggled oID.Diven to False")
Catch oEx As Exception
MsgBox("oID.Driven was True. Failed to toggle it to False." & vbCrLf & _
oEx.Message & vbCrLf & vbCrLf & _
oEx.StackTrace & vbCrLf & vbCrLf & _
oEx.Source,,"")
End Try
oPDoc.Update2(True)
Try
oThickness.Driven = True
MsgBox("Just toggled oThickness.Diven to True")
Catch oEx As Exception
MsgBox("oThickness.Driven was False. Failed to toggle it to True." & vbCrLf & _
oEx.Message & vbCrLf & vbCrLf & _
oEx.StackTrace & vbCrLf & vbCrLf & _
oEx.Source,,"")
End Try
ElseIf oID.Driven = False And oThickness.Driven = True Then
MsgBox("oID.Driven = False And oThickness.Driven = True")
Try
oThickness.Driven = False
MsgBox("Just toggled oThickness.Diven to False")
Catch oEx As Exception
MsgBox("oThickness.Driven was True. Failed to toggle it to False." & vbCrLf & _
oEx.Message & vbCrLf & vbCrLf & _
oEx.StackTrace & vbCrLf & vbCrLf & _
oEx.Source,,"")
End Try
oPDoc.Update2(True)
Try
oID.Driven = True
MsgBox("Just toggled oID.Diven to True")
Catch oEx As Exception
MsgBox("oID.Driven was False. Failed to toggle it to True." & vbCrLf & _
oEx.Message & vbCrLf & vbCrLf & _
oEx.StackTrace & vbCrLf & vbCrLf & _
oEx.Source,,"")
End Try
End If
oSketch.ExitEdit
oPDoc.Update2(True)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you for the time you took to review my posts and your effort to find a solution.
My thought was to have a foul constraint sketch, double dimensioning the parameter ID and make additional parameter (Wall_Thickness) with the intention to choose controlling the actual wall thickness from the parameter ID or Wall_Thickness.
I was thinking if this would possible to achieve this without making true false statement, I'm not quite sure if it will be doable by creating a List(Of String) and add ranges, I haven't tried yet but I don't think this would work either.
Best Regards.
Achilles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I think the best way to do this is by adding 2 dummy parameters. (InnerDiameter and WallThickness) A dummy parameter for InnerDiameter is maybe not what you expect. But you need it to see if the InnerDiameter or the WallThickness has been changed. As an example, I used a tube. In the screencast below you will see all parameters that i used.
And this is the iLogic code to make it work:
Dim wt As Double = WallThickness Dim id As Double = InnerDiameter Dim idr As Double = Parameter("InnerDiameterReal") Dim odr As Double = Parameter("OuterDiameterReal") If (DoubleUtil.DoublesAreEqual(id, idr)) Then ' wall thickness has been changed Parameter("InnerDiameterReal") = odr - 2 * wt Parameter("InnerDiameter") = odr - 2*wt Parameter("WallThickness") = wt Else ' inner diameter has been changed Parameter("WallThickness") = (odr - id)/2 Parameter("InnerDiameterReal") = id End If
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report