Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

resetting lineweight with vba problem 1

Status
Not open for further replies.

vbcad

Technical User
Jul 12, 2002
159
0
0
US
below is a bit of code from a vba macro. it works fine except for the linweight part. it sets all of the objects to bylayer for color, linetype but does not reset the lineweight to by layer. anyone see the issue?

For Each adEnt In adSS
adEnt.color = 256
adEnt.Lineweight = "ByLayer"
adEnt.Linetype = "ByLayer"
adEnt.Update
Next adEnt
End Sub
 
Hi vbcad,

The lineweight option want a number or in this case use the constant "acLnWtByLayer"

Code:
...
..
adEnt.Lineweight = acLnWtByLayer

HTH
Todd
 
Thanks. Below is the code for the routine. When run, the routine seems to be very slow. Is there something in the code i could do to make it faster or is the speed related to the amount of items in the selection set. i have a lisp version of this that runs faster. Isn't VBA supposed to be faster?

Sub EntityByLayer()
Dim adEnt As AcadEntity
Dim adSS As AcadSelectionSet
Dim fType(0) As Integer, fData(0)
On Error Resume Next
Set adSS = ThisDrawing.SelectionSets("adSS")
If Err Then Set adSS = ThisDrawing.SelectionSets.Add("adSS")
adSS.Clear
fType(0) = 0: fData(0) = "*"
adSS.Select acSelectionSetAll, , , fType, fData
For Each adEnt In adSS
adEnt.color = 256
adEnt.Linetype = "bylayer"
adEnt.Lineweight = acLnWtByLayer
adEnt.Update
Next adEnt
End Sub
 
Hi vbcad,

This might help:

Code:
Sub EntityByLayer()
  Dim adEnt As AcadEntity
  Dim adSS As AcadSelectionSet
  On Error Resume Next
  Set adSS = ThisDrawing.SelectionSets("adSS")
  If Err Then Set adSS = ThisDrawing.SelectionSets.Add("adSS")
  adSS.Clear
  adSS.Select acSelectionSetAll
  For Each adEnt In adSS
    adEnt.color = 256
    adEnt.Linetype = "bylayer"
    adEnt.Lineweight = acLnWtByLayer
    adEnt.Update
  Next adEnt
End Sub

or it may not. I don't think VBA is suppossed to be faster and if I'm not mistaken, I seem to remember something about LISP being faster because it is directly interpreted where as VBA has to jump though more hoops to talk to AutoCAD. (It's been a while so I don't remember all the details) but in short - no VBA is not faster.

HTH
Todd
 
i thought it was the other way around as far as speed goes. with the speed of most computers it is really hard to tell the difference anyway. the new code didnt make a difference on speed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top