Cutting a Solid in the API


#1

When I attempt to cut a solid within the API I am always left with this sort of situation, I’m sure others have encountered a similar problem.

I am curious why it leaves the residual face and lines?

Does anyone have a good workaround for this?


#2

Is this result different from when called from the UI?

I have very little experience with the native solid tools from the API. I more or less gave up on them when I realized they don’t modify the existing instances in place but instead creates new containers with new axes position and without the attributes. That is why I made my own solid operations, which are now open source.


#3

What commands are you using? I use pushpull from within scripts and haven’t seen any problems.

My strategy would be to add both edges at the top surface where you want to make the cut. Then get faces for each edge. Finally pushpull the common face.

I try to not use solid tools in scripts so that my scripts will work with SU Make.


#4

This is the result of a pushpull operation. I am first creating a face on the bottom of the plate via four points which forms a rectangle, then pushpull upwards.

I am trying to leave behind a solid made of two segments as shown.


#5

Nathan, I see what you mean.

Try creating 4 edges - 2 at the bottom of the plate and 2 opposing edges at the top of the plate. I think then you will find that it will work.


#6

Try this code in the ruby console and you will see what I mean:

@Plt_btm = 1.5
@Stud_depth = 5.5
@Bpltz = 0.0

@Plt1y1 = 0.0 - @Stud_depth
@Plt1y2 = 0.0 - @Stud_depth
@Plt1y3 = @Stud_depth - @Stud_depth
@Plt1y4 = @Stud_depth - @Stud_depth


pt1 = [0,@Plt1y1,0]
pt2 = [120,@Plt1y2,0]
pt3 = [120,@Plt1y3,0]
pt4 = [0,@Plt1y4,0]

group1 = Sketchup.active_model.active_entities.add_group
entities1 = group1.entities
	

new_face1 = entities1.add_face pt1, pt2, pt3, pt4
if @Bpltz == 0.0
	new_face1.pushpull -@Plt_btm
else	
	new_face1.pushpull @Plt_btm
end

pt1 = [12,@Plt1y1,0]
pt2 = [36,@Plt1y2,0]
pt3 = [36,@Plt1y3,0]
pt4 = [12,@Plt1y4,0]

new_face1 = entities1.add_face pt1, pt2, pt3, pt4

if @Bpltz == 0.0
	new_face1.pushpull -@Plt_btm
else	
	new_face1.pushpull @Plt_btm
end

#7

Strangely the code below works:

@Plt_btm = 1.5
@Stud_depth = 5.5
@Bpltz = 0.0

@Plt1y1 = 0.0 - @Stud_depth
@Plt1y2 = 0.0 - @Stud_depth
@Plt1y3 = @Stud_depth - @Stud_depth
@Plt1y4 = @Stud_depth - @Stud_depth


pt1 = [0,@Plt1y1,0]
pt2 = [120,@Plt1y2,0]
pt3 = [120,@Plt1y3,0]
pt4 = [0,@Plt1y4,0]

group1 = Sketchup.active_model.active_entities.add_group
entities1 = group1.entities
	

new_face1 = entities1.add_face pt1, pt2, pt3, pt4
if @Bpltz == 0.0
	new_face1.pushpull -@Plt_btm
else	
	new_face1.pushpull @Plt_btm
end



# Cut out door


pt1 = [12,@Plt1y1,0]
pt2 = [36,@Plt1y2,0]
pt3 = [36,@Plt1y3,0]
pt4 = [12,@Plt1y4,0]

new_face1 = entities1.add_face pt1, pt2, pt3, pt4


pt1 = [12,@Plt1y1,1.5]
pt2 = [36,@Plt1y2,1.5]
pt3 = [36,@Plt1y3,1.5]
pt4 = [12,@Plt1y4,1.5]

new_face1 = entities1.add_face pt1, pt2, pt3, pt4

if @Bpltz == 0.0
	new_face1.pushpull -@Plt_btm
else	
	new_face1.pushpull @Plt_btm
end

#8

Now I have to ask the reason why?


#9

Nathan - try it in the UI and you will see why.


#10

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.