AutoCad VBA Region intersect (command IN "Intersect")

AutoCad VBA Region intersect (command IN "Intersect")

jalal.mousa
Advocate Advocate
889 Views
2 Replies
Message 1 of 3

AutoCad VBA Region intersect (command IN "Intersect")

jalal.mousa
Advocate
Advocate

I am trying to write code subtract 2 region items

i found 1 way  using Autocad by 

command Region and select 2 closed polyline

Then

command IN (intersect)  select 2 region objects ("RegionRoom") & ("RegionTile") 

I search further and found that Boolean Method (ActiveX) may do the job 

object.Boolean(Operation, Object)
AutoCAD 2022 Developer and ObjectARX Help | Boolean Method (ActiveX) | Autodesk

 

I created two Region object by using code to convert two closed polylines

the issue is that i am getting mistake when trying to intersect between two

any recommendations how to solve it

 

jalalmousa_0-1677042618603.png

--Moderator edit: Put code into code window.

Dim MyApp As Object

Dim MyDWG As AcadDocument

Set MyApp = GetObject(, "Autocad.Application")

MyApp.Visible = True
Set MyDWG = MyApp.ActiveDocument


'GetEnt

Dim Tile As AcadLWPolyline

Dim Room As AcadLWPolyline

MyDWG.Utility.GetEntity Tile , pp, "Select a polyline: "

MyDWG.Utility.GetEntity Room, pp, "Select a polyline: "


Dim RegionRoom As Variant
Dim RegionTile As Variant

' set Region to match poly object


RegionRoom = MyDWG.ModelSpace.AddRegion(Room)

RegionTile = MyDWG.ModelSpace.AddRegion(Tile )

 

 

' in this part i am getting error result

Dim result As AcadRegion

Set result = RegionRoom(acSubtraction, RegionTile)

 

0 Likes
Accepted solutions (1)
890 Views
2 Replies
Replies (2)
Message 2 of 3

Ed__Jobe
Mentor
Mentor
Accepted solution

You need to pay attention to the syntax that is used in the help document that you linked to.

First, you didn't even use the Boolean method. Second, the method doesn't return a result, so you can't use the Set statement. The method just alters the object that calls the Boolean method by adding or subtracting the object specified in the argument. So it should look like this.

RegionRoom.Boolean acSubtraction, RegionTile

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 3

jalal.mousa
Advocate
Advocate

Thanks Ed

This is really very helpful

actually i tried first this way but for sure i did mistake with syntax i missed ".Boolean"

 

0 Likes