Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic Auto dimension bend extents in .IDW

Anonymous

iLogic Auto dimension bend extents in .IDW

Anonymous
Not applicable

ADBE.jpgHello, I wrote a code that creates the .IDW and places the view with the bend extents... but I can't figure out how to add the dimensions.

What I'm basically looking for is a piece of code that adds a dimension between the bend edges and the closest parallel bend extent. Because I need to know that number.

Thanks for any help 

0 Likes
Reply
1,087 Views
4 Replies
Replies (4)

GeorgK
Advisor
Advisor

@Anonymous

 

Please post your code. Than we can add the dimensions.

0 Likes

Anonymous
Not applicable

SyntaxEditor Code Snippet

Dim v_DocumentoPadre As AssemblyDocument = ThisApplication.ActiveDocument
Dim v_GeometriaT As TransientGeometry = ThisApplication.TransientGeometry  
Dim v_DefComEnsamb As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
Dim v_Operacion As PartFeature
Dim v_DocsReferenciados As DocumentsEnumerator = v_DocumentoPadre.AllReferencedDocuments 
Dim v_DocumentoRef As Document 
v_Matriz = v_GeometriaT.CreateMatrix

For Each Ocurrence In v_DefComEnsamb.Occurrences
If Ocurrence.Definition.Document.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Dim oSMDef As SheetMetalComponentDefinition
Dim REFDOC As PartDocument = Ocurrence.Definition.Document
oSMDef = REFDOC.ComponentDefinition
Dim oSheet As sheet
oApp = ThisApplication
Dim oBendNote As BendNote
Dim oBaseView As DrawingView
Dim oDrawingDoc As DrawingDocument
Try
Dim oFlatPattern As FlatPattern = oSMDef.FlatPattern
Dim oFace As Face = oFlatPattern.TopFace
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "TEMPLATE FULL PATH HERE", True)
oSheet= oDrawingDoc.ActiveSheet
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oBaseViewOptions As NameValueMap
oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
oBaseViewOptions.Add("SheetMetalFoldedModel", False)
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
oBaseView = oSheet.DrawingViews.AddBaseView(REFDOC,oTG.CreatePoint2d(10, 12),1/2,ViewOrientationTypeEnum.kDefaultViewOrientation,DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle,,,oBaseViewOptions)
oBaseView.DisplayBendExtents= True
REFDOC = oBaseView.ReferencedDocumentDescriptor.ReferencedDocument
oFlatPattern = REFDOC.ComponentDefinition.FlatPattern
Dim extension As Edges
extension = oFlatPattern.GetEdgesOfType(
FlatPatternEdgeTypeEnum.kTangentFlatPatternEdge)
Dim ejeabajo As Edges
ejeabajo = oFlatPattern.GetEdgesOfType(
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge)
Dim ejearriba As Edges
ejearriba = oFlatPattern.GetEdgesOfType(
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge)
If extension.Count=0 Then
'oDrawDoc.Close (True)
v_AnadirA105=v_DocumentoPadre.ComponentDefinition.Occurrences.AddVirtual("A 105 CURVAR",v_Matriz)
End If

'oDrawDoc.Close (True)
Catch
End Try
End If
Next


 

0 Likes

Anonymous
Not applicable

That's part of the code. In order to run... 3 things must take in count.

 

*    It's got to be run from an Assembly with sheetmetal parts inside.

*    Sheetmetal parts contained in the assembly must have unfolded.

*    And some text must be replaced with the full path of IDW template, to create the drawing. Where it reads "Template Full  Path"

 

If extension.Count=0 Then
'oDrawDoc.Close (True)
v_AnadirA105=v_DocumentoPadre.ComponentDefinition.Occurrences.AddVirtual("A 105 CURVAR",v_Matriz)
End If
HERE IS WHERE I WANT TO CREATE THE DIMENSIONS
'oDrawDoc.Close (True)
Catch
End Try
End If
Next

Thanks in advance.

0 Likes

JamieVJohnson2
Collaborator
Collaborator

It took me some practice adding dimensions in the drawing document, because it is definitely picky about input.

 

First, you want an Object Collection (examples below are from my own code, so use your own names), because when you're done adding these dims the collection can be used to clean them up, with the arrange command.

Dim ocSideViewSideDims As ObjectCollection = invApp.TransientObjects.CreateObjectCollection

sheet1.DrawingDimensions.Arrange(ocSideViewTopDims)

 

So with that end in mind,  here I am adding a Linear dimension to the drawing, and to the collection in one line.

ocSideViewTopDims.Add(sheet1.DrawingDimensions.GeneralDimensions.AddLinear(pDimText, giLoadShiftCenter, giLoadShiftRight, DimensionTypeEnum.kHorizontalDimensionType))

       

Function AddLinear(TextOrigin As Point2d, IntentOne As GeometryIntent, Optional IntentTwo As Object = Nothing, Optional DimensionType As DimensionTypeEnum = DimensionTypeEnum.kAlignedDimensionType, Optional ArrowheadsInside As Boolean = True, Optional DimensionStyle As Object = Nothing, Optional Layer As Object = Nothing) As LinearGeneralDimension

 

Getting GeometryIntent will be the biggest challenge, because it is so 'vague'.

 Function CreateGeometryIntent(Geometry As Object, Optional Intent As Object = Nothing) As GeometryIntent

I used Centerlines for the object (turned on, or included, from model workplanes),  Then using TransientGeometry(tg=invApp.TransientGeometry) create a pick point for placement that is relevant to that object.  Its like saying, here is a box solid, and here is the top right corner of that box solid.  Or Here is a centerline, and here is the end point on that centerline.

                Dim giLoadShiftCenter As GeometryIntent = sheet1.CreateGeometryIntent(clSideYZ, tg.CreatePoint2d(clSideYZ.StartPoint.X, cmMaxBottomSideView.Position.Y))
                Dim giLoadShiftRight As GeometryIntent = sheet1.CreateGeometryIntent(cmMaxRightSideView)
                pDimText = tg.CreatePoint2d(FindMid(clSideYZ.EndPoint.X, cmMaxRightSideView.Position.X), cmMaxTopSideView.Position.Y + (2 * DimOffset))

 

If it gives you 'EFail' its is likely the input doesn't work as you expected.  Your point may not be on your object, or your object may be missing altogether.  From there go back and trace your input values, and verify you are in-fact telling it not to jump off a cliff.

jvj
0 Likes