#1 Fri 01 May 2020 08:24
- kane1000
- Juste Inscrit !
- Date d'inscription: 1 May 2020
- Messages: 1
assistance
je dois construire un rectangle oblique à partir de 3 points mais ca donne pas!
aidez please
Include "MAPBASIC.DEF"
Include "ICONS.DEF"
Declare Sub Main
Declare Sub drawPLine
Sub Main
Alter ButtonPad ID 2
Add Separator
Add ToolButton
Icon MI_ICON_MISC_12
ID 103
Cursor MI_CURSOR_FINGER_LEFT
DrawMode DM_CUSTOM_POLYLINE
Calling drawPLine
HelpMsg "Draw the axis of the road Axis of the road"
Enable
Show
end sub
Sub drawPLine
dim nNode, nNode2, nNode3, nSegment, i as Integer
dim X3,Y3, X1,Y1,X2,Y2,fX,fY as Float
dim objPLine,pto4 as Object
dim LName as string
'Define the name of the topmost(non-cosmetic) layer
'It is assumend that the layer is vector
LName=LayerInfo(FrontWindow(), 1, LAYER_INFO_NAME)
'Define an object-polyline
objPLine = CommandInfo(CMD_INFO_CUSTOM_OBJ)
For nSegment = 1 To ObjectInfo(objPLine , OBJ_INFO_NPOLYGONS)
For i = 1 To 3
If i = 1 Then
nNode = 1
X1= ObjectNodeX(objPLine, nSegment, nNode)
Y1= ObjectNodeY(objPLine, nSegment, nNode)
end if
If i=2 then
nNode2 = 1+ nNode
X2= ObjectNodeX(objPLine, nSegment, nNode2)
Y2= ObjectNodeY(objPLine, nSegment, nNode2)
else
nNode3 = ObjectInfo(objPLine , OBJ_INFO_NPOLYGONS + nSegment)
X3= CentroidX(Offset( objPLine , 90, 5, "km"))
Y3= CentroidY(Offset( objPLine , 90, 5, "km" ))
End If
Next
Next
pto4= CreatePoint(X1,Y3)
nSegment = 1
nNode = 1
Alter Object objPLine
Node Add Position nSegment, nNode (CentroidX(pto4),CentroidY(pto4))
Insert Into LName (X, Y, Obj) Values (X, Y, CreateLine(X1,Y1,X2,Y1))
Insert Into LName (X, Y, Obj) Values (X, Y, CreateLine(X2,Y1,X3,Y3))
Insert Into LName (X, Y, Obj) Values (X, Y, CreateLine(CentroidX(pto4),CentroidY(pto4),X1,Y1))
Insert Into LName (X, Y, Obj) Values (X, Y, CreateLine(CentroidX(pto4),CentroidY(pto4),X3,Y3))
end sub
Hors ligne