2D Polygon generation w/VBA
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
2D Polygon generation w/VBA

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
postonz
Guest





Posted: Tue Dec 07, 2004 2:24 am    Post subject: 2D Polygon generation w/VBA Reply with quote

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

Back to top
Nathan Taylor
Guest





Posted: Tue Dec 07, 2004 3:08 am    Post subject: Re: 2D Polygon generation w/VBA Reply with quote

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
Back to top
Jorge Lopez
Guest





Posted: Tue Dec 07, 2004 3:11 am    Post subject: Re: 2D Polygon generation w/VBA Reply with quote

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@jiveforum2.autodesk.com...
Quote:
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


Back to top
postonz
Guest





Posted: Tue Dec 07, 2004 7:52 pm    Post subject: Re: 2D Polygon generation w/VBA Reply with quote

THANKS... Works for me.. (ME.SHOW 1)... GREAT...
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB