Results 1 to 4 of 4

Thread: 2D Polygon generation w/VBA

  1. #1
    postonz Guest

    2D Polygon generation w/VBA

    IF I use Addline... then UPDATE... see the modifications in drawing... IMMEDIATELY...
    IF I use SendCommand (POLYGON)... then UPDATE... The modifications are NOT IMMEDIATE...
    BUT when I go back to the Drawing... MODIFICATION are THERE... SEE VBA CODE...
    '==============================================
    Private Sub CommandButton4_Click()
    ' This example adds an DECAGON in model space... 10 SIDES POLYGON...
    Dim alineObj As AcadLine
    Dim startline(0 To 2) As Double '0=X...1=Y...2=Z
    Dim endline(0 To 2) As Double
    '================================================
    Set acadObj = GetObject(, "AutoCAD.Application") 'Set up old OBJECTS..
    Set AcadDoc = acadObj.ActiveDocument 'Set up old DOCUMENTS...
    '================================================
    ' Define data for new DECAGON base (box) '====== Begin at UCS Point =====
    ThisDrawing.SendCommand ("_POLYGON 10 e 0 2 ") 'Draws Polygon Perfectly
    acadObj.Update 'Will NOT UPDATE
    ThisDrawing.Application.ZoomExtents 'ZOOMS PERFECT
    '===================END OF PROGRAMMING =======
    End Sub

  2. #2
    Nathan Taylor Guest
    I think the problem is that with some commands SendCommand executes immediately but with a lot they do not execute until the code has finished.

    I see your code is making a 10 sided polgon. How many polygon variations do you need to create? I know it will be a lot more complicated but would it be possible to calculate the corners of the polygon and use the AddLightweightPolyline method.

    Good Luck - Nathan

  3. #3
    Jorge Lopez Guest
    The problem is that SendCommand is asynchronous and is not processing before
    your call Update. If your form is modal it wont execute at all until you
    dismiss it. See if the following works for you:

    Me.Hide ' added to your code

    ThisDrawing.SendCommand ("_POLYGON 10 e 0 2 ") 'Draws Polygon
    Perfectly
    acadObj.Update 'Will NOT UPDATE
    ThisDrawing.Application.ZoomExtents 'ZOOMS PERFECT

    Me.Show 1 ' added to your code

    Basically it just removes the modal dialog and re-displays it. I highly
    recommend you do not use SendCommand whenever possible.

    - Jorge


    "postonz" <nospam@address.withheld> wrote in message
    news:19441714.1102368321438.JavaMail.jive@jiveforu m2.autodesk.com...
    IF I use Addline... then UPDATE... see the modifications in drawing...
    IMMEDIATELY...
    IF I use SendCommand (POLYGON)... then UPDATE... The modifications are NOT
    IMMEDIATE...
    BUT when I go back to the Drawing... MODIFICATION are THERE... SEE VBA
    CODE...
    '==============================================
    Private Sub CommandButton4_Click()
    ' This example adds an DECAGON in model space... 10 SIDES POLYGON...
    Dim alineObj As AcadLine
    Dim startline(0 To 2) As Double '0=X...1=Y...2=Z
    Dim endline(0 To 2) As Double
    '================================================
    Set acadObj = GetObject(, "AutoCAD.Application") 'Set up old OBJECTS..
    Set AcadDoc = acadObj.ActiveDocument 'Set up old
    DOCUMENTS...
    '================================================
    ' Define data for new DECAGON base (box) '====== Begin at UCS Point
    =====
    ThisDrawing.SendCommand ("_POLYGON 10 e 0 2 ") 'Draws Polygon
    Perfectly
    acadObj.Update 'Will NOT UPDATE
    ThisDrawing.Application.ZoomExtents 'ZOOMS PERFECT
    '===================END OF PROGRAMMING =======
    End Sub

  4. #4
    postonz Guest
    THANKS... Works for me.. (ME.SHOW 1)... GREAT...

Similar Threads

  1. polygon resistance
    By mauricio in forum Cadence
    Replies: 4
    Last Post: 09-21-2005, 01:10 AM
  2. Slow DXF file generation in SW2006
    By TLS in forum SolidWorks
    Replies: 3
    Last Post: 09-16-2005, 09:10 AM
  3. Shape to Polygon
    By tracy&amanda in forum Cadence
    Replies: 4
    Last Post: 03-13-2005, 02:47 PM
  4. Replies: 3
    Last Post: 12-21-2004, 01:07 AM
  5. samreport log file generation
    By chanley in forum Network
    Replies: 9
    Last Post: 08-05-2004, 04:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum