See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Automatic dimensioning

  1. #1
    Member buddy.brooks's Avatar
    Join Date
    2006-03
    Location
    Lynchburg Virginia
    Posts
    38
    Login to Give a bone
    0

    Default Automatic dimensioning

    Hello

    I am a newbie. I have been programming in various languages since 1980. I have recently learned AutoLISP and I am now working on Autocad VBA. I have created a program to parametrically generate parts for our conveyors. The basic program generates a dialog box that request length, width, chain type, material thickness. I have two versions, one with a form that simply ask for data, the second displays a graphical representation of the formed part and has text boxes for entering the new dimensions. Not all of the text boxes are used in the code yet, it is a work in progress. At this time I can generate 10 width variations, any reasonable thickness, and any length entered. Our parts are usually 0.105 thick and up to 120" long. The holes are generated in different patterns depending on the choices. It's great for generating lengthwise variations at each width. What I cannot seem to figure out is how to create dimensions for the parts. Can anyone provide some basic sample code for adding dimensions programatically? Would using qdim or autodim help? I am using Autocad 2004 dx mechanical.

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,419
    Login to Give a bone
    0

    Default Re: Automatic dimensioning

    Each type of dim has an associated Add method, e.g. AddDimRotated. Each has sample code in the developer's guide, acad_dev.chm. You can also search this forum for "dimension".
    C:> ED WORKING....


    LinkedIn

  3. #3
    Member buddy.brooks's Avatar
    Join Date
    2006-03
    Location
    Lynchburg Virginia
    Posts
    38
    Login to Give a bone
    0

    Question Re: Automatic dimensioning

    Thanks for responding.
    I have been searching this forum and the entire web for about 6 weeks trying to find a good answer. The developers guide and help files don't give me enough information. I know that I can add a dimension, do I need to define a selection set first then execute the add. Could you show me an example. Attached is the code , I know it's a little sloppy and I have several commented areas where I have tried different ideas. I do not know the best way to write the code yet. It works up to a point.

    I have a plot template for the layout space that it winds up in. I still need to work on generating the layout instead of having it open in advance, but that's for another day. Right now I just need to get a glimpse of how to get the program to dimension the features. We use baseline dimensioning. I tried Qdim with sendcommand to answer the prompts but couldn't get it right. I really don't have a clue how to get started dimensioning.
    Attached Files Attached Files

  4. #4
    Member buddy.brooks's Avatar
    Join Date
    2006-03
    Location
    Lynchburg Virginia
    Posts
    38
    Login to Give a bone
    0

    Default Re: Automatic dimensioning

    I know that I am probably not asking this correctly but I will try again. I can see from the examples in acad_dev.chm how to add a single dimension. Is there any way to programatically add baseline dimensions in autocad 2004 dx? What would the corredct syntax be? Is there a way to use a feature like autodim or qdim to cut down on the size of code or am I going to have to duplicate the length and width logicof the main program to generate endpoints for the dimension lines? Is there an easy way to dimension holes for instance by using a selection set with a filter to choose say... all of the 0.31 dia holes with a "Y" dimension of 5.25?

  5. #5
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,419
    Login to Give a bone
    0

    Default Re: Automatic dimensioning

    You asked ok the first time, just be patient. Some questions involve more research than others. I'm afraid there is no "easy" way. VBA is limited when it comes to executing acad commands. You're going to have to get very familiar with dims and their properties if you want to code an automatic solution, e.g. there is no such thing as a basline dimension object. Its just a rotated dim with different settings, like one extension turned off. Another reason you need to know their props is related to your other post. In vba, the way you create new ents is first you Add it, then, retaining a pointer to the object just added, you manipulate its properties.
    C:> ED WORKING....


    LinkedIn

  6. #6
    Member buddy.brooks's Avatar
    Join Date
    2006-03
    Location
    Lynchburg Virginia
    Posts
    38
    Login to Give a bone
    0

    Smile Re: Automatic dimensioning

    I'm sorry i don't mean to seem impatient. I am not always sure how to ask the right question. I am reading everything that I can about it. I don't know if anyone has had a chance to look at the code yet. I haven't saved any pointers to access my entities as I created them, perhaps I should have done something differently there.

    I can generate individual dimensions by using this code:

    Dim dimobj As AcadDimAligned
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    Dim location(0 To 2) As Double

    ' Define the dimension
    point1(0) = 0: point1(1) = 0: point1(2) = 0#
    point2(0) = length1: point2(1) = 0: point2(2) = 0#
    location(0) = (lenght1 / 2): location(1) = -5: location(2) = 0#

    ' Create an aligned dimension
    Set dimobj = ThisDrawing.ModelSpace.AddDimAligned(point1, point2, location)
    ZoomAll

    Would this workas well:
    ThisDrawing.SendCommand " _dimordinate " & " 0,0 " & "0, -5.25, 0" & vbCR
    ThisDrawing.SendCommand "_dimbaseline 12, 5.25, 0 " & "12, -5,0" & vbCr

    I've seen comments to stay away from the "sendCommand" but this seems laike an easy way to do it if I can get the syntax right. I'll keep plugging away and check in from time to time. If I work it out I will post the code.

    Thanks again for your help

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,419
    Login to Give a bone
    0

    Default Re: Automatic dimensioning

    Correct. Now that you have dimobj pointing to a valid dim, you can change its props. Like put it on the DIM layer, turn of ext1, etc.

    The limitation with SendCommand is that it is asyncronous. If you want to use it just to generate a bunch of ents and you don't mind that they will get created after you vb is totally finished, then it might be ok. But don't expect to be able to create it with the baseline command and then grab the last ent and modify it. Also, you're going to end up with having to build the string at runtime. Instead of
    "_dimbaseline 12, 5.25, 0 " & "12, -5,0" & vbCr

    You'll need something with variables in it, e.g.
    "_dimbaseline " & point1 & etc

    You'll probably want to do this in a For loop, on each piece of geometry to dimension. But you will also have to do this for objects added via vba. Sometimes, a method I use to figure out what I want to accomplish is to enter a bunch of comments in vba, like
    Code:
    'Step 1
    
    'Step 2
    
    'Step 3
    This allows me to figure out the general outline of tasks that need to be performed and in what order. Then fill in the blanks.
    Last edited by Ed Jobe; 2006-06-06 at 08:12 PM.
    C:> ED WORKING....


    LinkedIn

  8. #8
    Member buddy.brooks's Avatar
    Join Date
    2006-03
    Location
    Lynchburg Virginia
    Posts
    38
    Login to Give a bone
    0

    Default Re: Automatic dimensioning

    Thanks,

    I'm starting to get an idea where to start. I'll tinker around with this and see how far I can get. I was hoping that there was some code foating around out there somewhere that I could us as a go by but I don't think that there is anything quite close enough. I would sure like to see how someone else has done this to avoid some of the pitfalls along the way. There are a lot of details to consider I guess pseudo code is probably the best tool for now.

    Thanks again, I'll check back to see if anyone else comes up with any other insight.

  9. #9
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,419
    Login to Give a bone
    0

    Default Re: Automatic dimensioning

    I think its a rather small niche, for those of you who make a small enough line of products that you can programatically produce dimensions. Most of us have to rely on our skills to do it because there are so many variables.
    C:> ED WORKING....


    LinkedIn

  10. #10
    Member buddy.brooks's Avatar
    Join Date
    2006-03
    Location
    Lynchburg Virginia
    Posts
    38
    Login to Give a bone
    0

    Smile Re: Automatic dimensioning

    Many products I have worked on had similar product lines and multiple variations. When
    changing to a new model, much of the old design usually carried over. It is easier to edit a program, And inspect the results once, then let the program generate the details.
    We have 10 model lines with common components. The length of each section can range from 12" to 120" by 32nds. Features are determined by the length and 10 widths with 3 thicknesses. We subcontract a lot parts due to volume. We provide formed and flat views that are dimensioned and annotated for cnc machining, cutting and punching. 300 variations at 12" lengths are (10 x 10 x 3). Each time a revision is made we have to regenerate the flat patterns. If we do not provide them we pay huge engineering charges.

    This situation was similar when I designed nuclear decontamination equip., printed circuit boards, HVAC - heat pump design, agricultural equipment, robotic work cells, metal office furniture, utility trailers and more.

    It allows the engineers to avoid mundane redundant generation of variations and spend time on challenging design task like new products, and interfaces to existing products from other vendors.

Page 1 of 2 12 LastLast

Similar Threads

  1. Dual dimensioning with tolerance Dimensioning with punctuation
    By Wish List System in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2014-10-22, 04:47 PM
  2. Automatic Dimensioning
    By M.Jamal Khan in forum AutoCAD General
    Replies: 4
    Last Post: 2010-07-21, 06:56 PM
  3. Automatic PDF-ing. Even possible?
    By schrodingerscat in forum Dot Net API
    Replies: 13
    Last Post: 2009-06-17, 02:09 AM
  4. Add Automatic Ordinate Dimensioning to IV
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 0
    Last Post: 2007-12-18, 12:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •