• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Employee
    Posts: 391
    Registered: ‎01-06-2009

    Re: Drawing Automation with VBA

    04-24-2011 08:49 PM in reply to: nttoan8187

    You can use AIGDT font to the FormattedText to show symbols:

     

    <StyleOverride Font='AIGDT' Bold='False'>n</StyleOverride>



    Rocky Zhang
    Inventor API
    Manufacturing Solutions
    Autodesk, Inc.

    Please use plain text.
    Valued Contributor
    nttoan8187
    Posts: 92
    Registered: ‎06-29-2010

    Re: Drawing Automation with VBA

    04-24-2011 09:44 PM in reply to: yuhanzhang

    Amazing!

    Could you please give me the materials for some special symbol in Format Text? I cannot find out where I can read them.

    For instance: DimensionValue, SectionViewName, etc........

     

     

    I got a problem in dimension that is I cannot use GeneralDimensions.AddLinear to dimension between a centerline and a line curve

     

    'oCLine100 is the center line, oLCurve100 is the line curve. Two lines is parallel. oDimPos is the point 2d

    Dim oGI100, oGI101 As GeometryIntent

    Set oGI100 = oSheet.CreateGeometryIntent(oLCurve100)

    Set oGI101 = oSheet.CreateGeometryIntent(oCLine100)

     

    Dim oLDim100 As LinearGeneralDimension

    Set oLDim100 = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oDimPos100, oGI100, oGI101, kDiametricDimensionType)

     

    Please help me to figure out what goes wrong in the code????

     

    This GeneralDimensions.AddLinear() is really terrible. It make my Inventor crash down more than 15 time per day........... although I use "On Error Resume Next" before the code line or not.

    Please mark this answer as Problem Solved if it solves your question.
    -----------------------------------------------------------------------------------------
    Toan
    Inventor API
    Please use plain text.
    Valued Contributor
    nttoan8187
    Posts: 92
    Registered: ‎06-29-2010

    Re: Drawing Automation with VBA

    04-25-2011 12:19 AM in reply to: nttoan8187

    Sometimes, the problem shows out like this following figure:

    pic5.JPG

     

    But sometimes, Inventor crash down like this

    pic6.JPG

    For average 30 minutes for one crash like this. If I use the GeneralDimensions.AddLinear 3 or 4 times, it crash down immediately.

    Autodesk men, please check out, I am tired of crash and reopen Inventor and crash and reopen..................................so annoyed

    If you can find out the solution, please make the hot-fix for it!!!!!!!!!!!

    Please mark this answer as Problem Solved if it solves your question.
    -----------------------------------------------------------------------------------------
    Toan
    Inventor API
    Please use plain text.
    Employee
    Posts: 391
    Registered: ‎01-06-2009

    Re: Drawing Automation with VBA

    04-25-2011 01:34 AM in reply to: nttoan8187

    In API help, you can search the topic titled "XML Tags for FormattedText" to understand more details about FomattedText.

     

    Can you attach a data to reproduce the failure for adding the diametric linear dimension?

     



    Rocky Zhang
    Inventor API
    Manufacturing Solutions
    Autodesk, Inc.

    Please use plain text.
    Valued Contributor
    nttoan8187
    Posts: 92
    Registered: ‎06-29-2010

    Re: Drawing Automation with VBA

    04-25-2011 02:27 AM in reply to: yuhanzhang

    Sorry, but it is the company properties, I don't have the permission to attach.......

    But I really DO NOT understand why.

     

    First,

    I change the code to dimension for two line segment curves, which is only different in Y position, every else is same.

    Then I create the Center Line by two kStartPoint of two lines, it worked

    This means that these two GeometryIntent are right. Then the AddLinear() not work with these two GeometryIntent

    If I don't create CenterLine AddLinear also didn't work!!!!!!! Run two or three time, Inventor crashs down........

    ---> Unbelievable

     

    Then, I change to the most simple case. I get two geometry intent that is the StartPoint and EndPoint of a line curve.

    AddLinear didn't work too. What happens??????????

    Do you believe this?????

     

    In two case, I change the color and weight of curves, and it work well---> this means that the curves is not nothing and they are right!

     

    So, assuming that I don't understand and I write wrong code?????? Why Inventor crashes??????????? Today, I got more than 20 crashes, it is really irritated.

     

    I know that this sounds stupid, but it was. Now I will try to make a sample to test and send for you........

     

    Please mark this answer as Problem Solved if it solves your question.
    -----------------------------------------------------------------------------------------
    Toan
    Inventor API
    Please use plain text.
    Valued Contributor
    nttoan8187
    Posts: 92
    Registered: ‎06-29-2010

    Re: Drawing Automation with VBA

    04-25-2011 03:05 AM in reply to: nttoan8187

    I just create a simple test, it can work, and the List of Properties/Methods can work also

    In my macro, even I press Ctrl+J, it not work??????

    Or the wrong thing happens because my code is too long???????????????

    About 3000 lines and will be 5000 lines if I can use AddLinear to dimension the drawing..................

    How I can solve this problem???? Please help!!!!

    Please mark this answer as Problem Solved if it solves your question.
    -----------------------------------------------------------------------------------------
    Toan
    Inventor API
    Please use plain text.
    Employee
    Posts: 391
    Registered: ‎01-06-2009

    Re: Drawing Automation with VBA

    04-25-2011 03:49 AM in reply to: nttoan8187

    If the data is protected, can you create another simple sample  to reproduce the issue which you think is safe to attach? Or you can try to select a line segment curve on a drawing, and then run below VBA code to check if it works:

     

    Sub CreateLinearDiametricDim()
        Dim oDoc As DrawingDocument
        Set oDoc = ThisApplication.ActiveDocument
        
        Dim oCurve As DrawingCurve
        Set oCurve = oDoc.SelectSet(1).Parent
         
        Dim oIntent1 As GeometryIntent, oIntent2 As GeometryIntent
        Set oIntent1 = oDoc.ActiveSheet.CreateGeometryIntent(oCurve, kStartPointIntent)
        Set oIntent2 = oDoc.ActiveSheet.CreateGeometryIntent(oCurve, kEndPointIntent)
        
        Dim oDim As LinearGeneralDimension
        Dim oPt As Point2d
        Set oPt = ThisApplication.TransientGeometry.CreatePoint2d(12, 12)
        Set oDim = oDoc.ActiveSheet.DrawingDimensions.GeneralDimensions.AddLinear(oPt, oIntent1, oIntent2, kDiametricDimensionType)
    End Sub

     

     

    As the issue for display the List of Properties/Methods, can you check if there are two subs which have the same name in the module/class?



    Rocky Zhang
    Inventor API
    Manufacturing Solutions
    Autodesk, Inc.

    Please use plain text.
    Valued Contributor
    nttoan8187
    Posts: 92
    Registered: ‎06-29-2010

    Re: Drawing Automation with VBA

    04-26-2011 02:41 AM in reply to: yuhanzhang

    I just think to new solution that doesn't need to dimension automatic by VBA anymore.

    Maybe in my next project, we will discuss more. Thank you so much!

     

    I have a question about DrawingView:

     

    How I can Delete the oBaseView but still exist the oIsoView????

     

    If we do this manually, we can choose No when a prompt appear and ask us to Delete Projected Views or not

    But I don't see any option in DrawingView.Delete() method.

    Please mark this answer as Problem Solved if it solves your question.
    -----------------------------------------------------------------------------------------
    Toan
    Inventor API
    Please use plain text.
    Valued Contributor
    nttoan8187
    Posts: 92
    Registered: ‎06-29-2010

    Re: Drawing Automation with VBA

    04-26-2011 07:01 PM in reply to: nttoan8187

    Sorry for me,

    I just try and only the obaseview is deleted; the isoview still be there. It's no need to do anything else, thanks IV for this!

    Please mark this answer as Problem Solved if it solves your question.
    -----------------------------------------------------------------------------------------
    Toan
    Inventor API
    Please use plain text.