Create "Linear Diameter" with iLogic

Create "Linear Diameter" with iLogic

iogurt1
Advocate Advocate
2,797 Views
8 Replies
Message 1 of 9

Create "Linear Diameter" with iLogic

iogurt1
Advocate
Advocate

Hey everyone. I've been working on drawing automation in the past few weeks and I've had some success, thanks to this forum. But once again I am stuck and all the Googling couldn't help me out: I want to create a "linear diameter" in a detail view. For this, I include the centerline of the part and the work point I want to dimension to. All good so far. The part I can't figure out is how to change the dimension to a "linear diameter". If I create the dimension the same way I create most of my other dimensions, I (understandably) get the distance between the work point and the centerline. See picture for what I am trying to achieve.

 

My code snippet to create all other linear dimensions looks like this:

Dim oTHKOD As GeneralDimension
oTHKOD  = oGeneralDims.AddLinear(oPt7, intent10, intent11)

 

Any help is greatly appreciated!

PS: Does it make sense to create a new post everytime I have a new question (there will be a few more I'm sure) or should I create a general "drawing automation" post where I post future questions as well? 

0 Likes
Accepted solutions (1)
2,798 Views
8 Replies
Replies (8)
Message 2 of 9

Jon.Balgley
Alumni
Alumni

Hi --

 

Regarding multiple posts -- IMHO, it's best to have separate threads when it's a "new question".  If it's really an extension of the "same question", then add to the existing thread.  Does that help?  I lean towards making new threads when in doubt.

 

For this topic, which kind of dimension are you trying to create, A or B?

 

lin-dia-dim.jpg


Jon Balgley
0 Likes
Message 3 of 9

iogurt1
Advocate
Advocate

Hey Jon

I agree, next time I'll create a new post if the questions is not related the last one.

As for the dimension A or B: Neither. See attached picture. I am trying to show a Ø in a detail view. For that, I "include" the axis of the part, dimension from my OD to the center axis, right click and choose "Linear Diameter". I am wondering what the iLogic code for that would look like.

0 Likes
Message 4 of 9

Jon.Balgley
Alumni
Alumni
Accepted solution

OK, well, that was harder than I expected!  But here you go:

 

SyntaxEditor Code Snippet

' iLogic-isms
Dim vw As DrawingView
vw = ActiveSheet.View("VIEW1").View

Dim sh As Sheet
sh = ActiveSheet.Sheet



' Interactive selection for testing purposes.
Dim doc as DrawingDocument
doc = ThisDoc.Document

If (doc.SelectSet.Count <> 2) Then Exit Sub 

Dim oCurve1 As DrawingCurve
oCurve1 = doc.SelectSet(1).Parent  ' <-- This should be a drawing curve

Dim oCurve2 As Object
oCurve2 = doc.SelectSet(2) '  <-- This should be a centerline.



'Real API stuff below 
Dim oIntent1 As GeometryIntent
oIntent1 = sh.CreateGeometryIntent(oCurve1)
        
Dim oIntent2 As GeometryIntent
oIntent2 = sh.CreateGeometryIntent(oCurve2, oCurve1.StartPoint)  '  <-- Need to fine-tune the 'intent' 

Dim oPt As Point2d
oPt = ThisApplication.TransientGeometry.CreatePoint2d(60, 40) ' <-- random position 

Dim genDims as GeneralDimensions
genDims = sh.DrawingDimensions.GeneralDimensions

Dim oLinDim As LinearGeneralDimension
' Need to use "diametric"
oLinDim = genDims.AddLinear(oPt, oIntent1, oIntent2, Inventor.DimensionTypeEnum.kDiametricDimensionType) 




 


Jon Balgley
Message 5 of 9

iogurt1
Advocate
Advocate

And once again, it works exactly the way I wanted it to. Thanks Jon!

 

One thing I was always wondering about, is: how do you know that 

kDiametricDimensionType

can be part of 

Inventor.DimensionTypeEnum

 ? Is there a list somehwere online where that's all mapped out? I have a beautifully printed 36" x 24" poster on my wall of the "AUTODESK INVENTOR 2014 API OBJECT MODEL" (link: http://images.autodesk.com/adsk/files/Inventor2014Model.pdf ) but it doesn't go deep enough for my liking. Is there an extended version that shows things like what I mentioned above?

Thanks again

0 Likes
Message 6 of 9

Jon.Balgley
Alumni
Alumni

I use the API help document.  Under "?" in the Inventor window title bar, there is "Help" and then "Programming/API Help".  In the topic for GeneralDimensions.AddLinear, it describes the "DimensionType" argument as "DimensionTypeEnum".  That's a clickable link.  It takes you to the topic for DimensionTypeEnum, which lists all legal values.

 

The "Object Browser" in the VBA editor will give you this info, too.

 

AFAIK, there is no single chart that has all of this detail in one diagram.  

 

Keep those questions coming!


Jon Balgley
Message 7 of 9

iogurt1
Advocate
Advocate

Good to know. I will definitely dive into the help menu and start reading up on things 🙂

0 Likes
Message 8 of 9

iogurt1
Advocate
Advocate

Hey Jon. Can you please explain how "B" is created in the picture you posted earlier? Do I have to create 2 workplanes, 1 at the bottom of the hole, 1 on top? Or can I just import the one round surface and dimension top to bottom? Thanks

0 Likes
Message 9 of 9

Jon.Balgley
Alumni
Alumni

You dimension between the two "apparently-linear" drawing curves.  In the image below, I created the dimension by clicking on the top "line" of the hole, and then  the bottom "line".  You would do the same thing in code, AFAIK.

 

Capture.JPG


Jon Balgley
0 Likes