VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

could you tell me sth

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
195 Views, 3 Replies

could you tell me sth

hi,

here is my codes,i cannot find the problem( functions of CreateSelectionSet
and rule are ok)
could you tell me sth .
thank you.

------------------------------------
Sub linesharepoint(BaseLine As AcadLine)
Dim removeObjects(0) As AcadEntity
Dim addObjects(0) As AcadEntity
Dim SelectObj1 As AcadSelectionSet
Set SelectObj1 = CreateSelectionSet--
Dim SelectObj2 As AcadSelectionSet
Set SelectObj2 = CreateSelectionSet
n = 0
For Each line In ThisDrawing.ModelSpace
If line.entityName = "AcDbLine" Then
Set addObjects(0) = line
SelectObj1.AddItems addObjects
n = n + 1
End If
Next
Set removeObjects(0) = BaseLine
SelectObj1.RemoveItems removeObjects
SelectObj2.AddItems removeObjects
Redo:
n = 0
Do Until n = SelectObj1.Count + 1
If rule(BaseLine, SelectObj1.Item(n)) Then
Set removeObjects(0) = SelectObj1.Item(n)
SelectObj1.RemoveItems removeObjects
SelectObj2.AddItems removeObjects
Set BaseLine = SelectObj1.Item(n)
Exit Do 'End If
'Next
n = n + 1
Loop
goto Redo
For Each line In SelectObj2
line.Highlight (True)
Next
End Sub '
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Start by simplifying your code. Any time you're crawling through a
drawing looking for entities with specific properties, you might
consider the use of filtered selection sets. See if using the code below
doesn't help clear up your problem.

Dim ss As AcadSelectionSet
Dim fType(1) As Integer
Dim fData(1) As Variant
Dim line As AcadLine

fType(0) = 0: fData(0) = "LINE"
fType(1) = 67: fData(1) = 0
Set ss = CreateSelectionSet()
ss.Select acSelectionSetAll, , , fType, fData
'at this point, you have all the lines in model space
For Each line In ss
'do your thing
Next

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Message 3 of 4
Anonymous
in reply to: Anonymous


Can you tell us what the function/sub is supposed to do? Judgeing from the name "linesharepoint" I would guess that this is a function the returns True or False if two lines share a point (i.e. intersect) but I don't believe that's the case.



What does the Rule function do? What type of value does it return?

Message 4 of 4
Anonymous
in reply to: Anonymous

thanks a lot.

what i want to do is that,

when i select a line on the screen ,the
line that shears the same endpoint or startpoint will be caught and so on and
on.

as the result of the sub,i get continuous
lines

thank you.

 

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Can you tell us what the function/sub is supposed to do? Judgeing from the
name "linesharepoint" I would guess that this is a function the returns True
or False if two lines share a point (i.e. intersect) but I don't believe
that's the case.


What does the Rule function do? What type of value does it return?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report