Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

scale with vba 1

Status
Not open for further replies.

bjod

Mechanical
Feb 7, 2003
37
0
0
NO
Hi everyone!

This is my first post here at the autocadforum.

I'm a CATIA V5 user and I'm trying to write a macro which saves the CATIA drawings as dwg's, opens them up and gives them the right scale.The macro will be run from CATIA VBA.
I'm basically trying to select everything in the drawing in AutoCAD, and then scaling it with 0,0,0 as basepoint.
(the drawings come out in wrong scale after conversion)
When I run this in a macro from within AutoCAD, it runs very fast, but when I run it from CATIA, it creeps along very slowly.

Our converted CATIA drawings often have about 15000 objects, so I was wondering wheter there was is way to scale all objects simultaneously instead of one by one.

here's the code I'm using after opening up the drawing:

**************************

Dim objecttoselect3 As AcadSelectionSet
Set objecttoselect3 = oDrawing.SelectionSets.Add("SSET1")
Dim corner1(0 To 2) As Double
corner1(0) = 0: corner1(1) = 0: corner1(2) = 0

objecttoselect3.Select acSelectionSetAll
objecttoselect3.Highlight True
AcadApplication.Update

Dim indrawing As Double
indrawing = objecttoselect3.Count

i = 0
Do
objecttoselect3.Item(i).ScaleEntity corner1, 20

i = i + 1
Loop Until i = indrawing


******************

I hope anybody have some suggestions to make my macro run faster, and thanks for taking the time.

-Bjod

 
Replies continue below

Recommended for you

Why don't you just process this via the command line? Instead of creating a selection set of a ton of entities, utilize the "ALL" method already built into AutoCAD.
Code:
ThisDrawing.SendCommand "_Scale" & vbCr & "ALL" & vbCr & vbCr & "0,0,0" & vbCr & "4" & vbCr
This will scale everything on the active drawing by a scale of 4 with the base point of 0,0.

Hope that helps...


DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Hi dsi.

Your solution worked really well, I got my processing time down from about a minute to half a second!
Thank you very much!! :)

-Bjod
 
glad to help...

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Status
Not open for further replies.
Back
Top