Create Dimension between two points in idw

Create Dimension between two points in idw

iogurt1
Advocate Advocate
7,521 Views
60 Replies
Message 1 of 61

Create Dimension between two points in idw

iogurt1
Advocate
Advocate

I am slowly getting into drawing automation with iLogic and I've already learned a lot just watching the video on http://www.symetri.co.uk/blog/details/automating-dimensions-with-ilogic

 

I copied their iLogic code to try it for myself and creating a linear dimension between two faces works great.

I also got the code to work if I want to place a diameter on a round object

 

What I am now struggling with, is to create a linear dimension between two work points that are set to "include" in the idw. I think it has something do with with the way I am defining the work points. For the faces, the code snippet that defines the edges looks like this:

 

'finds edges with a particular attributes then taks the first instance
Dim aoEdge3 as face
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "RHS", "1")
aoEdge3 = oObjs.Item(1)

'Finds the drawing edge that represents the one with the attribute
Dim aoDrawCurves4 As DrawingCurve
oDrawViewCurves = oView.DrawingCurves(aoEdge4)
aoDrawCurves4 = oDrawViewCurves.Item(1)

 

What I don't know, is how to define the work points. I tried to define the aoDrawCurves4 As Point2d but that didn't work. 

Any help is appreciated.

 

 

0 Likes
Accepted solutions (1)
7,522 Views
60 Replies
Replies (60)
Message 2 of 61

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi iogurt1,

 

Have a look at this link. particularly page 23 of the PDF file:

https://forums.autodesk.com/autodesk/attachments/autodesk/120/58687/1/MA316-5,ConfiguratorTips.pdf

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 3 of 61

iogurt1
Advocate
Advocate

Thanks Curtis!

One other thing I have been wondering about: Is there a list somewhere where I can find all the available options for "Dim ... As ..."? 

 

"Dim MyExpression As <WhatAreMyOptions?>"

 

DrawingDocument, Sheet, DrawingView, TransientGeometry, face, GeneralDimensions and so on... where can I learn about the available options?

Thanks again.

0 Likes
Message 4 of 61

Curtis_Waguespack
Consultant
Consultant

Hi iogurt1,

 

Have a look at the API help as mentioned at this link:

http://inventortrenches.blogspot.com/2013/10/ilogic-how-to-learn-inventors.html

 

The API help has sample files, as well as some Getting Started and Overview information.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

EESignature

Message 5 of 61

iogurt1
Advocate
Advocate

Just in case someone else stumbles over this thread and is looking for a list of available API objects that can be used in the iLogic code, check out this pdf: http://images.autodesk.com/adsk/files/Inventor2014Model.pdf

0 Likes
Message 6 of 61

Anonymous
Not applicable

Did this work for you? I am using the attribute helper mentioned in the link you posted. Or the one mentioned in this video:

https://www.youtube.com/watch?v=bcOvYc6rNUk

I am using a vertex proxy and am trying to make the dimensions between the two.

0 Likes
Message 7 of 61

iogurt1
Advocate
Advocate

Hi EMiller29. Yes I've been creating a lot of automated drawings since my post. It's really cool once it works 🙂

 

A few tips:

- I have made it a habit of creating one rule per view. Depending on how many dimensions you are creating, this is an easier way to troubleshoot the code and keep it clean and tidy.

- Anything in the code below that is in "" you have to adjust to what you have in your model/drawing (i.E. View "A", change the "A" to whatever your view is named).

 

My "standard" code for pretty much any part I want to have an automated drawing for looks like this. It's nicely organized I feel and you can use it for many other drawings by making minor adjustments. This example is to create a diameter dimension between 2 workpoints that "travel" with the Inner Diameter of the part (meaning they move if my Diameter increases or decreases), add a diameter symbol in front and center the text and add attributes so they can be deleted when you run that iLogicCreatedDelete rule that is mentioned in the video you linked to.

 

SyntaxEditor Code Snippet

'---INITIAL SETUP---------

'References this document
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDoc.Document

'References this drawing sheet
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

'References this drawing view
Dim oView As DrawingView
oView = ActiveSheet.View("A").View

'References all drawing views
Dim oViews as DrawingViews
oViews = oSheet.DrawingViews

'References this drawing view model
Dim oPartDoc As PartDocument
oPartDoc = ActiveSheet.View("A").ModelDocument

'Readys code for Creation of reference points for dimension placement
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

'Readys code for creation of general dimensions
Dim oGeneralDims As GeneralDimensions
oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions

'---DIMENSION PREP------------

'finds point with a particular attribute then takes the first instance
Dim WorkPoint1 As WorkPoint
oObjs = oPartDoc.AttributeManager.FindObjects("DIM", "PT_ID_TOP", "1")
WorkPoint1 = oObjs.Item(1)

Dim WorkPoint2 As WorkPoint 
oObjs = oPartDoc.AttributeManager.FindObjects("DIM", "PT_ID_BTM", "1")
WorkPoint2 = oObjs.Item(1)

'"includes" work point in the view and turns them into centermarks so we 'can dimension To them
Dim marks(2) As Centermark
marks(0) = oSheet.Centermarks.AddByWorkFeature(WorkPoint1, oView)
marks(0).Visible = False
marks(1) = oSheet.Centermarks.AddByWorkFeature(WorkPoint2, oView)
marks(1).Visible = False

'creates intents, needed for Inventor to know that we want to use these points to'create dimensions further down in the code 
Dim intent1 As GeometryIntent
intent1 = oSheet.CreateGeometryIntent(marks(0))
Dim intent2 As GeometryIntent
intent2 = oSheet.CreateGeometryIntent(marks(1))

'ID position for dimension
Dim oPt1 As Point2d
oPt1 = oTG.CreatePoint2d(oView.Left - 1)

'---CREATING DIMENSIONS------------

'creates ID dimension to the left of the view
Dim oID As GeneralDimension
oID = oGeneralDims.AddLinear(oPt1, intent1, intent2)
oID.CenterText
'adds ø-symbol in front Of dimension value
Dim oIDText As DimensionText = oID.Text
oIDText.FormattedText = <DimensionValue/>"

'---ADDING ATTRIBUTES TO DIMENSIONS------------

'Adds an attribute to the dimensions. This is necessary to automatically'delete them when the "Delete_iLogic_Created" rule is run.
Dim oDim1Att As AttributeSet
ODim1Att = oID.AttributeSets.Add("iLogic_Created")
ODim1Att = oID.AttributeSets.Add("ID")

 

 

I hope that helps. If you have any questions about the code or for any other options you want to build into your drawing, don't hesitate to hit me up 🙂

 

 

Message 8 of 61

Anonymous
Not applicable

So, if I am reading this correctly you are making a vertex proxy into a work point made from the attribute helper?

0 Likes
Message 9 of 61

iogurt1
Advocate
Advocate

Not sure if the term "vertex proxy" is correct but I am "including" the work points from the model. I have each given them an attribute in the 3d Model (see below picture). It's the code equivalent of finding these points in the browser in the drawing and right-clicking on them and say "include". They then show up as centermarks. In the code I am doing the same thing and at the same time turning off their visibility. And further down the code I add a dimension between intent1 and intent2 that have been created on these points.

 

AttributeHelper.PNG

0 Likes
Message 10 of 61

Anonymous
Not applicable

Middle dim.JPGMiddle dim-1.JPG

 

So the highlighted dimension I am having a problem with. No matter what I do with the code it will not move.... I want it off to the left and can't figure out how to move it. It would be greatly appreciated if I could get any help on this! 🙂

FYI this all works great 😄 Other then the dimension I am asking about.

0 Likes
Message 11 of 61

iogurt1
Advocate
Advocate

You have to update the position of your oPt3. Right now you have it set at (oView.Left + (oView.Width/2), oView.Top - (oView.Height) +1). This means that in the horizontal direction, your dimension is placed at exactly the center of your view because your point starts off at the very left of the view (oView.Left) and then you move it to the right by half the width of the view (oView.Width/2). If you want to have the dimension to the left you could do something like oView.Left - 1. That would place it 1cm to the left (yes, all these numbers used on the drawing are always in Centimeter for some reason). And for this dimension you don't even need to specify a point from oView.Top because you probably want to center the dimension value between the arrows.

 

Note: oView.Left and oView.Top are the only starting points for dimension placement. oView.Right and oView.Bottom do not exists. So if you want to have that same dimension on the right of your view, you'd have to say oView.Left + oView.Width + 1

Message 12 of 61

Anonymous
Not applicable

Yes, I have tried the oview.left-1 and there is still no movement of the dimension. Is it because of it being angled?

0 Likes
Message 13 of 61

iogurt1
Advocate
Advocate

Hmm yeah I just tried the same thing on my part. I don't have many angled surfaces that's why I haven't seen this yet. So I set it to oView.Left - 3 and it worked. Not 100% sure where it's measuring these centimeter dimensions from... Hope the same will work for you, just increase the number on the offset.

0 Likes
Message 14 of 61

Anonymous
Not applicable

Is there a way to make the dimension perpendicular to the view?? I am very new to all of this but I am learning a whole lot!

0 Likes
Message 15 of 61

iogurt1
Advocate
Advocate

There is, yes. You can tell the dimension to be either vertical, horizontal or aligned to the view by adding one of the following options to your code:

 

DimensionTypeEnum.kHorizontalDimensionType

DimensionTypeEnum.kVerticalDimensionType

DimensionTypeEnum.kAlignedDimensionType

 

you add this to the same line with the intents and oPt:

 

 

.AddLinear(oPt3, intent1, intent3, DimensionTypeEnum.kHorizontalDimensionType)

 

Note: I have never actually used the DimensionTypeEnum.kAlignedDimensionType, only the horizontal and vertical ones. Maybe I should try it 😄

Message 16 of 61

Anonymous
Not applicable

Well it all works amazingly! Except for the one dimension from earlier 😕

Thank you so much for your help!!

0 Likes
Message 17 of 61

Anonymous
Not applicable

I am also guessing there is a way to tell the dimensions the layer and style to be on as well?

0 Likes
Message 18 of 61

iogurt1
Advocate
Advocate

The only other thing I can think of is a mistake I made in the beginning when I copied code from another dimension and didn't correctly update it for the new dimension. Is your dimension really linked to oPt3 or is it maybe still referencing oPt2 or one of the other ones from another dimension?

0 Likes
Message 19 of 61

iogurt1
Advocate
Advocate
Message 20 of 61

Anonymous
Not applicable

I am sorry I keep bothering you... but you have been extremely helpful!!

I am wanting to put my text underneath my dimension ex:

 

   1234

 top plate

 

 

 

Is there a way to make that happen?

0 Likes