centerpoints

centerpoints

X1JIANGWOO
Participant Participant
627 Views
17 Replies
Message 1 of 18

centerpoints

X1JIANGWOO
Participant
Participant
Hello guys,

I am trying to create a program the notifies the user if a circle on one layer shares a centerpoint with a circle on another layer.

Basically, we have a "stud" layer and an "etch" layer. The etch layer tells the laser to etch a reference circle so studs can be welded in the proper spot. What is happening is the etch circle is missing or off center when the drawing is completed. I am trying to find a way to run a program when finalizing the drawing so we know that all studs have the "etch" circles attached. Both circles are brought into the drawing when inserting blocks but when there is customization, things get moved or deleted.

Any advice is greatly appreciated.
0 Likes
628 Views
17 Replies
Replies (17)
Message 2 of 18

Anonymous
Not applicable

easiest might be....

 

erase all etch circles

for each stud circle

    copy @

    change to etch
layer

Next stud circle

 

else you'd have to

    For each stud
circle

        For
each etch circle


size=2>            look
for match

        Next
etch

    Next stud

lots of excess processing there

 

hth

mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hello
guys, I am trying to create a program the notifies the user if a circle on one
layer shares a centerpoint with a circle on another layer. Basically, we have
a "stud" layer and an "etch" layer. The etch layer tells the laser to etch a
reference circle so studs can be welded in the proper spot. What is happening
is the etch circle is missing or off center when the drawing is completed. I
am trying to find a way to run a program when finalizing the drawing so we
know that all studs have the "etch" circles attached. Both circles are brought
into the drawing when inserting blocks but when there is customization, things
get moved or deleted. Any advice is greatly
appreciated.
0 Likes
Message 3 of 18

X1JIANGWOO
Participant
Participant
How would I go about starting this? I'm new to VBA. Edited by: X1JIANGWOO on Nov 19, 2008 5:41 PM
0 Likes
Message 4 of 18

Anonymous
Not applicable
>>Both circles are brought into the drawing when inserting blocks but when there is customization, things get moved or deleted

So, each pair of stud/etch circles are in a block? How is it *one* of these gets moved without the other?
0 Likes
Message 5 of 18

Anonymous
Not applicable

Are the circles all in model space?

are the layer names exactly what you
wrote?


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
How
would I go about starting this? I'm new to VBA. Edited by: X1JIANGWOO on Nov
19, 2008 5:41 PM
0 Likes
Message 6 of 18

X1JIANGWOO
Participant
Participant
When the block is exploded because some sort of customizing is required, there usually is a lot of stretching and moving.
0 Likes
Message 7 of 18

Anonymous
Not applicable

If the etch circles are to be the same size as the
stud circles this might work

Sub StudEtchCircles()
  Dim oEnt As
AcadEntity
  Dim oCirc As AcadCircle
 
  'DELETE ETCH
CIRCLES
  For Each oEnt In ThisDrawing.ModelSpace
   
If TypeOf oEnt Is AcadCircle Then
      If
UCase(oEnt.Layer) = "ETCH" Then
       
oEnt.Delete
      End If
    End
If
  Next oEnt
 
  'COPY STUD CIRCLES TO
ETCHLAYER
  For Each oEnt In
ThisDrawing.ModelSpace
    If TypeOf oEnt Is AcadCircle
Then
      If UCase(oEnt.Layer) = "STUD"
Then
        Set oCirc =
oEnt.Copy
        oCirc.Layer =
"ETCH"
      End If
    End
If
  Next oEnt
 
 
End Sub

  hth

mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
When
the block is exploded because some sort of customizing is required, there
usually is a lot of stretching and moving.
0 Likes
Message 8 of 18

Anonymous
Not applicable
When the blocks are modified or moved. We rarely use the etch layer so sometimes modifications are accidentally done with out the layer being on. Sometimes, the etch is forgotten when making a custom block,
0 Likes
Message 9 of 18

Anonymous
Not applicable
Mark, I think your idea is great. Unfortunately the stud circles have a different size than the etch circle. It doesn't matter what size the stud circle is but all etch circles are to be 1 size. Is there a way I could set all of the circles(now on the etch layer) all to 1 size?
0 Likes
Message 10 of 18

Anonymous
Not applicable

Yes,

read the help on acad circle

they have a radius and diameter
property

set that (whichever one you want to use) in the
code after creating the etch circle

hth

mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Mark,
I think your idea is great. Unfortunately the stud circles have a different
size than the etch circle. It doesn't matter what size the stud circle is but
all etch circles are to be 1 size. Is there a way I could set all of the
circles(now on the etch layer) all to 1 size?
0 Likes
Message 11 of 18

Anonymous
Not applicable
Mark,

Thanks for all of the help. How would I modify the code so I delete every circle on the etch layer but the ones with a diameter of 3? Or just copy only the circles that do not have a diameter of 3? I've tried many different ways but I get errors. I'm not familiar with the typeof methods.

Thanks,

Xi
0 Likes
Message 12 of 18

Anonymous
Not applicable

if Not oCircle.Diameter = 3 then

    oCircle.Delete

...

 

be aware of rounding issues with that kind of thing
(floating point values in any computer system)

 

you can also apply a fuzz factor to get ones that
are virtually =3 but maybe show as 2.9999999999999 etc

 

eg

Function EqualFuzz(a As Double, b As Double, fuzz
As Double) As Boolean
  If Abs(a - b) < fuzz
Then
    EqualFuzz = True
  Else
   
EqualFuzz = False
  End If
End Function

hth

mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Mark,
Thanks for all of the help. How would I modify the code so I delete every
circle on the etch layer but the ones with a diameter of 3? Or just copy only
the circles that do not have a diameter of 3? I've tried many different ways
but I get errors. I'm not familiar with the typeof methods. Thanks,
Xi
0 Likes
Message 13 of 18

Anonymous
Not applicable
Thanks again Mark.

This is what I have for code:

{code}

Sub cetch()

Dim oEnt As AcadEntity
Dim oCirc As AcadCircle


'DELETE ETCH CIRCLES
For Each oEnt In ThisDrawing.ModelSpace

If TypeOf oEnt Is AcadCircle Then

If UCase(oEnt.Layer) = "ETCH" Then

If Not oCirc.Diameter = 3 Then

oCirc.Delete

End If

End If

End If

Next oEnt

{code}

I keep getting a "Object variable or With block variable not set" error. I'm sure this something I'm doing fundamentally wrong. The closer I look at it the further away from the answer I go.

Do I need to set the diamter?
0 Likes
Message 14 of 18

Anonymous
Not applicable

I forget if you are doing this in dbx or in the
editor?

if in editor you could also use filtered selection
for part of this

what line are you getting the error on, and can you
post so the lines don't all run together?

mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks
again Mark. This is what I have for code: {code} Sub cetch() Dim oEnt As
AcadEntity Dim oCirc As AcadCircle 'DELETE ETCH CIRCLES For Each oEnt In
ThisDrawing.ModelSpace If TypeOf oEnt Is AcadCircle Then If UCase(oEnt.Layer)
= "ETCH" Then If Not oCirc.Diameter = 3 Then oCirc.Delete End If End If End If
Next oEnt {code} I keep getting a "Object variable or With block variable not
set" error. I'm sure this something I'm doing fundamentally wrong. The closer
I look at it the further away from the answer I go. Do I need to set the
diamter?
0 Likes
Message 15 of 18

Anonymous
Not applicable
I am using the editor.

I get the error at "If Not oCirc.Diameter = 3 Then"



Sub cetch()

Dim oEnt As AcadEntity

Dim oCirc As AcadCircle



'DELETE ETCH CIRCLES

For Each oEnt In ThisDrawing.ModelSpace

If TypeOf oEnt Is AcadCircle Then

If UCase(oEnt.Layer)= "ETCH" Then

If Not oCirc.Diameter = 3 Then

oCirc.Delete

End If

End If

End If

Next oEnt



I get the error at line "If Not oCirc.Diameter = 3 Then"







0 Likes
Message 16 of 18

Anonymous
Not applicable

you never cast the oEnt to the oCirc

so either replace oCirc with oEnt or set oCirc =
oEnt when you find it is a circle

 


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

I am using the editor.

I get the error at "If Not
oCirc.Diameter = 3 Then"



Sub cetch()

Dim oEnt As
AcadEntity

Dim oCirc As AcadCircle



'DELETE ETCH
CIRCLES

For Each oEnt In ThisDrawing.ModelSpace

If TypeOf oEnt
Is AcadCircle Then

 

 '<---------- here you can Set
oCirc = oEnt to get intellisense on the properties of a
circle

size=2>


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
'-------------- then instead of using oEnt use
oCirc ... it's not necessary but makes code more explicit

' all entity types derive from AcadEntity but
each type has its own additional properties specific to itself

' eg a line has .Startpoint, a circle has .Center
....etc etc


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

 


If UCase(oEnt.Layer)= "ETCH" Then

If Not oCirc.Diameter = 3
Then

oCirc.Delete

End If

End If

End If


Next oEnt



I get the error at line "If Not
oCirc.Diameter = 3
Then"







0 Likes
Message 17 of 18

Anonymous
Not applicable
Mark,

I knew it was something simple. Thanks for all of the help.

Xi
0 Likes
Message 18 of 18

Anonymous
Not applicable

You're welcome

glad it worked

mark

🙂


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Mark,
I knew it was something simple. Thanks for all of the help.
Xi
0 Likes