model railroad track planning

This forum is for 'Work-in-Progress' QCAD user developed script Add Ons and Plug-ins.

Please use this forum to request/submit your script Add-Ons & Plug-in idea's.

Moderators: andrew, Husky, J-J

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4931
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: model railroad track planning

Post by Husky » Sat Jan 21, 2017 4:34 am

smf wrote:I'm still playing around with QCad and QCTrack, but it "just works", so there was no need for an update.
Hi smf - glad to hear that! I updated your library file list. :wink:
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

smf
Premier Member
Posts: 177
Joined: Tue Feb 28, 2012 1:05 pm

Re: model railroad track planning

Post by smf » Mon Feb 11, 2019 8:40 pm

Hi there,

somewhere before QCad 3.21 there were some changes that I completely missed. Sorry! :oops: So the version 101 of QCTrack does not work with the current version of QCad. After massive help of Andrew (thank you!) I will upload an updated QCTrack version for the next official QCad version as soon as possible.

Regards - smf

smf
Premier Member
Posts: 177
Joined: Tue Feb 28, 2012 1:05 pm

Re: model railroad track planning

Post by smf » Sat Apr 27, 2019 2:36 pm

Hi there,

sorry for the long offline-time (read: family-time). Attached is the new QCTrack version 102 which is tested with QCad 3.22.0 and seems :wink: to work. If you have any problems, please report them here.

@Husky: if you're still here, please update the "newest version" thread. Thank you! :D

@Andrew: thank you for your help and special QCad-extension! :) :) :)

Best regards
smf
Attachments
QCTrack_V102_QCad3220.zip
(76.82 KiB) Downloaded 2436 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4931
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: model railroad track planning

Post by Husky » Sun Apr 28, 2019 9:40 am

Done! :wink:
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

smf
Premier Member
Posts: 177
Joined: Tue Feb 28, 2012 1:05 pm

Re: model railroad track planning

Post by smf » Wed Jul 26, 2023 7:47 am

Unfortunatly, QCTrack is broken starting with QCad 3.24.0 onwards. Maybe there were some changes to the API of line-block-positions which I am not able to nail down or fix at the moment. I'm sorry and can not foresee when QCTrack will be fixed.
Last edited by smf on Wed Jul 26, 2023 11:59 am, edited 1 time in total.

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Re: model railroad track planning

Post by andrew » Wed Jul 26, 2023 11:40 am

Can you try this change in function getClosestTrackEnd in QCTrack.js:

var line = data.queryEntity(subIds[k], true);

The true argument means that the returned entity will be transformed according to block transformations. The default is false.

The same change is likely needed in getClosestTrackStraightMid.

smf
Premier Member
Posts: 177
Joined: Tue Feb 28, 2012 1:05 pm

Re: model railroad track planning

Post by smf » Thu Jul 27, 2023 7:11 am

Thank you for your fast response, indeed the added true-parameter fixes adding new tracks. :) I looked for other occurences and tried to add this parameter, but sometimes the complete library is broken, sometimes only parts of it work. It will take some time to test each occurence, but now I have a plan. Thanks again! :D

smf
Premier Member
Posts: 177
Joined: Tue Feb 28, 2012 1:05 pm

Re: model railroad track planning

Post by smf » Thu Jul 27, 2023 12:40 pm

Most things seem to work now, one thing to do is getting "selected" property of a line of a block depending on the selection of the block. Until 3.23 I did something like:

Code: Select all

  var k, subIds = document.queryBlockEntities(data.getReferencedBlockId());
  for (k = 0; k < subIds.length; k++) {
    var line = data.queryEntity(subIds[k]); //starting with 3.24, add "true" parameter to get absolute coordinates instead of block coordinates
    if (!line.isSelected()) { ... } //always returns false starting with 3.24 <<< how to do now?
Maybe there is a more elegant way to get only entities of selecteded blocks, or what would be the preferred way to get the "selected" property?

Thanks in advance!

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Re: model railroad track planning

Post by andrew » Thu Jul 27, 2023 1:12 pm

It's the block reference that is selected, not the individual entities inside the block definition.

You'd have to query the selection status of the block reference. In your function that is: block.isSelected().

smf
Premier Member
Posts: 177
Joined: Tue Feb 28, 2012 1:05 pm

Re: model railroad track planning

Post by smf » Thu Jul 27, 2023 1:19 pm

Thanks, that's it! Leaving me with the question, why I did not do this before - it is more elegant, a lot faster... e_confused

smf
Premier Member
Posts: 177
Joined: Tue Feb 28, 2012 1:05 pm

Re: model railroad track planning

Post by smf » Thu Jul 27, 2023 2:40 pm

Hi there,

thanks to Andrew's help, attached is the new QCTrack version 103 which is tested with QCad 3.24.0 / 3.27.6 / 3.28.1 and seems :wink: to work. If you have any problems, please report them here.

@Husky: if you're still here, please update the "newest version" thread. Thank you! :D

Best regards
smf
Attachments
QCTrack_V103_QCad3276.zip
(80.38 KiB) Downloaded 1724 times

Post Reply

Return to “QCAD 'Script Add-On & Plug-in challenge' - Work in Progress”