Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
When drawing a simple line using the sample VB API code, a line appears in the drawing but the wrong place consistently.
Using the code below, a line is expected from 0,0 to 20,0
Dim start As IpfcPoint3D
Dim finish As IpfcPoint3D
model = creoSession.CurrentModel
start = New CpfcPoint3D
start.Set(0, 0)
start.Set(1, 0)
start.Set(2, 0)
finish = New CpfcPoint3D
finish.Set(0, 20)
finish.Set(1, 20)
finish.Set(2, 0)
geom = (New CCpfcLineDescriptor).Create(start, finish)
lineInstructions = (New CCpfcDetailEntityInstructions).Create(geom, Nothing)
drawing.CreateDetailItem(lineInstructions)
When I check the coordinates again, they show correct values.
MessageBox.Show("Start = " & start.Item(0).ToString & " x " & start.Item(1).ToString & vbCrLf &
"End = " & finish.Item(0).ToString & " x " & finish.Item(1).ToString
)
Am I missing any transformation?
Solved! Go to Solution.
Thank you for the reply @YaroslavSin and my sincere apologies for the delay.
The hint is helpful, but it will be immensely helpful if you could also point to how the online/offline help could be accessed and any code snippet for the transformation of screen coordinates to drawing coordinates.
I have tried this meanwhile:
' define line start and end point
Dim startPt As IpfcPoint3D
Dim endPt As IpfcPoint3D
startPt = New CpfcPoint3D
startPt.Set(0, 0)
startPt.Set(1, 0)
startPt.Set(2, 0)
endPt = New CpfcPoint3D
endPt.Set(0, 20)
endPt.Set(1, 20)
endPt.Set(2, 0)
Dim scrTrans As IpfcScreenTransform = (New CCpfcScreenTransform).Create(startPt, endPt, Nothing)
Can you please tell, with code, how to transform these points to drawing coordinates.
Thanks, in advance.
Best,
Tushar
Did you find solution for this?
Regards,
Prasad
Not yet. Still waiting for a solution.
From the documentation:
The VB API methods and properties that manipulate drawings generally use screen coordinates.
You need to transform drawing coordinates to screen coordinates before to put it into a method.
Thank you for the reply @YaroslavSin and my sincere apologies for the delay.
The hint is helpful, but it will be immensely helpful if you could also point to how the online/offline help could be accessed and any code snippet for the transformation of screen coordinates to drawing coordinates.
I have tried this meanwhile:
' define line start and end point
Dim startPt As IpfcPoint3D
Dim endPt As IpfcPoint3D
startPt = New CpfcPoint3D
startPt.Set(0, 0)
startPt.Set(1, 0)
startPt.Set(2, 0)
endPt = New CpfcPoint3D
endPt.Set(0, 20)
endPt.Set(1, 20)
endPt.Set(2, 0)
Dim scrTrans As IpfcScreenTransform = (New CCpfcScreenTransform).Create(startPt, endPt, Nothing)
Can you please tell, with code, how to transform these points to drawing coordinates.
Thanks, in advance.
Best,
Tushar
Thanks @RandyJones
I was using VB API as mentioned in the original post.
For that, I found a more relatable post here:
The required lines are:
Dim currSheet As Integer = creoDrawing.CurrentSheetNumber
Dim sheetTransform As IpfcTransform3D = creoDrawing.GetSheetTransform(currSheet)
sheetTransform.Invert()
Dim startPtSheet As IpfcPoint3D = sheetTransform.TransformPoint(startPt)
Dim endPtSheet As IpfcPoint3D = sheetTransform.TransformPoint(endPt)
@Prasad_G - Please note 👆
@TusharS wrote:
Thanks @RandyJones
I was using VB API as mentioned in the original post.
For that, I found a more relatable post here:
Most of the time JLink, WebLink, and VB are very similar so seeing how to do any of them will help. In fact in this case it lead you to an VB specific article!