×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

scale with vba

scale with vba

scale with vba

(OP)
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

RE: scale with vba

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.

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.

RE: scale with vba

(OP)
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

RE: scale with vba

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources