LayOut API, Layout::Path trouble, please help

Hi there,
Please help me solve this trouble. I tried to re-draw a Layout::Path base on an existing Path in the document. Then I got another Path with exactly the same #point_types but have different shape.
Here’s the code:

def  self.draw_path(entity,x,y)
			start = entity.bounds.upper_left
			points = entity.points.map{|po| po.set!(po.x - start.x + x, po.y - start.y + y)}
			point_types = entity.point_types
			style = entity.style
			i = 0
			path2 = ''
			while i < points.length-1

				case point_types[i+1]
				when Layout::Path::POINT_TYPE_BEZIER_CONTROL	
					if i == 0
						path2 = Layout::Path.new(points[i],points[i+1],points[i+2],points[i+3])
					else
						path2.append_point(points[i+3],points[i+1],points[i+2]) 
					end
					i += 3
				when Layout::Path::POINT_TYPE_LINE_TO
					if i == 0
						path2 = Layout::Path.new(points[i],points[i+1])
					else
						path2.append_point(points[i+1])
					end						
					i += 1
				else
					# do arc or circle, later :(
					return
				end
			end			
			path2.style = style
			return path2
		end

And the result


Please help me
Thanks a lot!!!
Regards

I found the problem. It’s because of the API:


I changed the syntax to #append_point(control_point1,control_point2,point), then it worked
Maybe they should edit the API page to correct it :wink:
Regards

2 Likes

Thank you for bringing this to our attention! We will update the documentation for future releases of the API.

Adam

3 Likes

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