Author Topic: Swap Pre-Modelled CID Fittings  (Read 3325 times)

0 Members and 1 Guest are viewing this topic.

Offline nacnudTopic starter

  • Active Member
  • **
  • Posts: 41
  • Country: gb
  • Gender: Male
Swap Pre-Modelled CID Fittings
« on: Feb 07, 2024, 09:59:06 AM »
Hi, does anybody know a better modification tool than swap-in? we develop ductwork from the coordination stage to the manufacture stage, and so we may need to use a different CID part from that which was originally used (a straight bit of duct can be 3 or more different CID parts) we use swap in but that only exchanges an item of identical size etc.
It would be great if you could change the CID whilst retaining all the geometry and data from the existing items? a tall order probably.

Offline Darren Young

  • Premier Member
  • *****
  • Posts: 2133
  • Country: us
  • Gender: Male
    • BIM There Done That.
Re: Swap Pre-Modelled CID Fittings
« Reply #1 on: Feb 13, 2024, 21:54:32 PM »
You can programmatically change one CID to another fairly easily.

That said...you can easily turn a piece straight duct (866) into a piece of pipe (2041) which makes no sense. The dims/options aren't the same.

So while doing this...you'll want to program each CID combination....if one CID always maps to another....you can extract the dims/options from the one CID and push them to the proper places of the other.

No swap in required.

Offline Ty_

  • Active Member
  • **
  • Posts: 23
  • Country: us
  • Gender: Male
Re: Swap Pre-Modelled CID Fittings
« Reply #2 on: Jan 13, 2026, 20:07:08 PM »
I've been taking a deep dive into this via the the scripting language and the Fabrication API. Also been working on a modified version of the FabricationSample Add-In using AI (Claude CLI). It's done a pretty good job of adding features but, the Swap In is still a hangup. Essentially it will swap the item successfully but, can't place it back on the design line. Here's what it returned.

      Key Findings

  COD Script Approach (SwapCID.cod)

  - Uses item.Load(itmName) which replaces the item IN PLACE - this preserves position
  - Stores connector EndLocation using item.EndLocation(1, "X"), item.EndLocation(1, "Y"), etc.
  - Critical limitation: Even COD scripting notes on line 109: "Manual redraw/redevelop required in CADmep to restore 3D position"

  Fabrication API Limitations

  - Service.LoadServiceItem() creates a NEW item rather than replacing in-place
  - There is no direct API method to set connector endpoint positions
  - There is no programmatic access to the Redevelop command

  Changes Made

  Updated MoveItemWithOffset() (ItemSwapService.cs:478-550) to:
  1. Primary method: Use SendStringToExecute with AutoCAD's MOVE command
    - Format: _.MOVE (handent "handle")  0,0,0 @offsetX,offsetY,offsetZ
    - This uses native CAD move functionality which may work better for Fabrication items
  2. Fallback: Direct entity transformation if SendStringToExecute fails

  Remaining Limitation

  Items on designlines (nodes/fittings) are constrained by their connections to adjacent items. Even with the MOVE command, they may resist repositioning because:
  - They're part of a connected run/route
  - Their position is determined by adjacent item connections
  - Manual redevelop or reconnection may be required

  Recommendation

  For items on designlines, after swapping you may need to:
  1. Select the swapped item in AutoCAD
  2. Use the MAPREDEVELOP command to regenerate geometry
  3. Or manually grip-edit the item to reconnect it to the run

Will be curious if anyone is able to crack it because I've blown all my tokens for the day  ;D
Tyler Phillips
Business Development + Estimator at Harris
Email: tphillips@harriscompany.com
Cell: 740-692-2608