Automatic Ordinate Set Dimensions

Automatic Ordinate Set Dimensions

clive.w66LR9
Contributor Contributor
883 Views
7 Replies
Message 1 of 8

Automatic Ordinate Set Dimensions

clive.w66LR9
Contributor
Contributor

Hello all, 

 

The Below code creates a General Dimension between to defined faces,

I have tried but with no luck to change this to work with a Ordinate Set Dimension.

With "_End Stud:1" being the origin. 

I tried to use the link below to get it work.

https://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-488C8D53-8A2E-4A83-8181-C6191DC873B0https...

 

It seems to be a issue with defining a (DrawingCurveSegment)

 

 

Dim Doc As DrawingDocument
Doc = ThisDoc.Document 

Dim oSheet As Sheet
oSheet = Doc.ActiveSheet
 
Dim oView As DrawingView
oView = oSheet.DrawingViews(1)

Dim oAsmDoc As AssemblyDocument
oAsmDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    
Dim oCompDef  As AssemblyComponentDefinition
oCompDef = oAsmDoc.ComponentDefinition

Dim FPColl As ObjectCollection
Dim OverallColl As ObjectCollection
Dim oText As Point2d

Dim S1 = oCompDef.Occurrences.ItemByName("_End Stud:1")
Dim S2 = oCompDef.Occurrences.ItemByName("_Left Stud:1")

FPColl = ThisServer.TransientObjects.CreateObjectCollection
OverallColl = ThisServer.TransientObjects.CreateObjectCollection

Dim namedEntities = iLogicVb.Automation.GetNamedEntities(S1.Definition.Document)
Dim S1Face As Face = namedEntities.FindEntity("Face1")

Call S1.CreateGeometryProxy(S1Face, oSketchProxy)
Dim S1Curve = oView.DrawingCurves(oSketchProxy)

oIntent = oSheet.CreateGeometryIntent(S1Curve.Item(1))
Call OverallColl.Add(oIntent)

namedEntities = iLogicVb.Automation.GetNamedEntities(S2.Definition.Document)
Dim S2Face As Face = namedEntities.FindEntity("Face1")

Call S2.CreateGeometryProxy(S2Face, oSketchProxy)
Dim S2Curve = oView.DrawingCurves(oSketchProxy)

oIntent = oSheet.CreateGeometryIntent(S2Curve.Item(1))
Call OverallColl.Add(oIntent)

oText = ThisServer.TransientGeometry.CreatePoint2d(oView.Center.X - oView.Width / 2, oView.Center.Y - oView.Height / 2)

oText.Y = oText.Y - 1

Call oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oText, OverallColl.Item(1), OverallColl.Item(2)).CenterText

 

 any help will be appreciated 

0 Likes
Accepted solutions (1)
884 Views
7 Replies
Replies (7)
Message 2 of 8

clive.w66LR9
Contributor
Contributor
Accepted solution

for anybody that could use it, i got it to work

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
 
Dim oView As DrawingView
oView = oSheet.DrawingViews(1)

Dim oAsmDoc As AssemblyDocument
oAsmDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    
Dim oCompDef  As AssemblyComponentDefinition
oCompDef = oAsmDoc.ComponentDefinition

Dim FPColl As ObjectCollection
Dim OverallColl As ObjectCollection
Dim oText As Point2d

Dim S1 = oCompDef.Occurrences.ItemByName("_End Stud:1")
Dim S2 = oCompDef.Occurrences.ItemByName("_Left Stud:1")

FPColl = ThisServer.TransientObjects.CreateObjectCollection
OverallColl = ThisServer.TransientObjects.CreateObjectCollection

'[S1
Dim namedEntities = iLogicVb.Automation.GetNamedEntities(S1.Definition.Document)
Dim S1Face As Face = namedEntities.FindEntity("Face1")

Call S1.CreateGeometryProxy(S1Face, oSketchProxy)
Dim S1Curve = oView.DrawingCurves(oSketchProxy)

oIntent = oSheet.CreateGeometryIntent(S1Curve.Item(1))
Call OverallColl.Add(oIntent)
']
'[S2
namedEntities = iLogicVb.Automation.GetNamedEntities(S2.Definition.Document)
Dim S2Face As Face = namedEntities.FindEntity("Face1")

Call S2.CreateGeometryProxy(S2Face, oSketchProxy)
Dim S2Curve = oView.DrawingCurves(oSketchProxy)

oIntent = oSheet.CreateGeometryIntent(S2Curve.Item(1))
Call OverallColl.Add(oIntent)
']


   
oText1 = ThisServer.TransientGeometry.CreatePoint2d(oView.Center.X - oView.Width / 2, oView.Center.Y - oView.Height / 2)


'Create Ordinate Dimenson

Dim geomIntents As ObjectCollection
geomIntents = ThisApplication.TransientObjects.CreateObjectCollection
Call geomIntents.Add(OverallColl.Item(1))
Call geomIntents.Add(OverallColl.Item(2))

Call oSheet.DrawingDimensions.OrdinateDimensionSets.Add(geomIntents, oText1, kHorizontalDimensionType)

0 Likes
Message 3 of 8

SebastianMK
Participant
Participant

Thanks for Sharing this Code 👍

It works great if the Occurences are in the first Level of the Assembly.

 

In my Case the Occurences with the Named Faces are inside of an Subassembly in my Main Assembly.

And I get the Error:  Inventor.ComponentOccurrences.get_ItemByName(String Name) when running the Rule.

 

Does someone have an idea how to change the rule to run thru all the Levels of the Assembly and find the Named Face with  Occurence.ItemByName

 

This is the code so far:

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
 
Dim oView As DrawingView
oView = oSheet.DrawingViews(1)

Dim oAsmDoc As AssemblyDocument
oAsmDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    
Dim oCompDef  As AssemblyComponentDefinition
oCompDef = oAsmDoc.ComponentDefinition

Dim FPColl As ObjectCollection
Dim OverallColl As ObjectCollection
Dim oText As Point2d

'The Problem here might be that the Occurence is not in the first Level of the Assembly but in a subassembly
'Maybe we need to define in which Parent Occurence we want to look (Stand Occ 1 or Stand Occ 2)
Dim S1 = oCompDef.Occurrences.ItemByName("50.09.0062 - Plate:1") Dim S2 = oCompDef.Occurrences.ItemByName("50.09.0062 - Plate:1") FPColl = ThisServer.TransientObjects.CreateObjectCollection OverallColl = ThisServer.TransientObjects.CreateObjectCollection 'If we could work with our Points that we know insted of Faces then it would work '[S1 Dim namedEntities = iLogicVb.Automation.GetNamedEntities(S1.Definition.Document) Dim S1Face As Face = namedEntities.FindEntity("Start") Call S1.CreateGeometryProxy(S1Face, oSketchProxy) Dim S1Curve = oView.DrawingCurves(oSketchProxy) oIntent = oSheet.CreateGeometryIntent(S1Curve.Item(1)) Call OverallColl.Add(oIntent) '] '[S2 namedEntities = iLogicVb.Automation.GetNamedEntities(S2.Definition.Document) Dim S2Face As Face = namedEntities.FindEntity("End") Call S2.CreateGeometryProxy(S2Face, oSketchProxy) Dim S2Curve = oView.DrawingCurves(oSketchProxy) oIntent = oSheet.CreateGeometryIntent(S2Curve.Item(1)) Call OverallColl.Add(oIntent) '] oText1 = ThisServer.TransientGeometry.CreatePoint2d(oView.Center.X - oView.Width / 2, oView.Center.Y + oView.Height) 'Create Ordinate Dimenson Dim geomIntents As ObjectCollection geomIntents = ThisApplication.TransientObjects.CreateObjectCollection Call geomIntents.Add(OverallColl.Item(1)) Call geomIntents.Add(OverallColl.Item(2)) Call oSheet.DrawingDimensions.OrdinateDimensionSets.Add(geomIntents, oText1, kHorizontalDimensionType)

Best Regards 

 

Sebastian

 

0 Likes
Message 4 of 8

clive.w66LR9
Contributor
Contributor

try change 

oView.ReferencedDocumentDescriptor.ReferencedDocument

To

 oView.ReferencedDocumentDescriptor.AllReferencedDocuments

 

 

0 Likes
Message 5 of 8

SebastianMK
Participant
Participant
Unfortunately AllReferencedDocuments is not a Member of the DocumentDescriptor
0 Likes
Message 6 of 8

clive.w66LR9
Contributor
Contributor

I’m not sure if it’s even going to help your overall problem, 

but you can get down to the level like this

 

Dim oAsmDoc As AssemblyDocument

oAsmDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

Dim  refDoc As Document In oAsmDoc.ReferencedDocuments

 

And so on

0 Likes
Message 7 of 8

krishnaprasad.veedu
Contributor
Contributor

@SebastianMK : Hi, were you able to get a solution for your issue, I have got a similar issue when my named entities are inside a subassembly? any luck? thanks.

0 Likes
Message 8 of 8

JMGunnar
Collaborator
Collaborator

If you want too GetIntet in subassembly from drawingview

 

LeftPoint = oView.GetIntent({"Bottomsection","Flatbar Diagonales" },"LeftFace" )

 FlatBar Diagonals is component in subassembly Bottomsection 

 

@krishnaprasad.veedu @SebastianMK 

 

Best Regards Johan

0 Likes