Results 1 to 7 of 7

Thread: Xref insert using dimscale

  1. #1
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    406
    Login to Give a bone
    0

    Default Xref insert using dimscale

    Hi everyone,

    I need help finishing this program. I can't figure out how to get this to scale the xref file by one over the dimscale when it inserts it into the drawing file.

    Code:
    (defun c:ZDTL ( / xrefLayer osnapMode originalOsnapMode xrefFile insertPoint scaleFactor xrefDoc xrefBlock)
      ;; Load COM libraries
      (vl-load-com)
    
      ;; Set the desired settings
      (setq xrefLayer "XREF")
      (setq osnapMode 4)
    
      ;; Get the current osmode value
      (setq originalOsnapMode (getvar "osmode"))
    
      ;; Turn on osnap mode
      (setvar "osmode" osnapMode)
    
      ;; Prompt the user to select the file to Xref
      (setq xrefFile (getfiled "Select Xref file" "" "dwg" 1))
    
      ;; If a valid file path is selected, proceed
      (if xrefFile
        (progn
          ;; Open the Xref file in the background to get DIMSCALE
          (setq xrefDoc (vla-open (vla-get-documents (vlax-get-acad-object)) xrefFile :vlax-false))
          ;; Retrieve the DIMSCALE value from the Xref file
          (setq scaleFactor (vla-getvariable xrefDoc "DIMSCALE"))
          ;; Close the document
          (vla-close xrefDoc)
    
          ;; Prompt the user to select the insertion point
          (setq insertPoint (getpoint "\nEnter insertion point for Xref: "))
    
          ;; Convert the insertion point to a 3D point for ActiveX
          (setq insertPoint (vlax-3d-point insertPoint))
    
          ;; Insert the Xref as an overlay with ActiveX
          (setq xrefBlock
                (vla-attachexternalreference
                  (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
                  xrefFile     ;; File path of the Xref
                  (vl-filename-base xrefFile)  ;; Block name (using file name without extension)
                  insertPoint   ;; Insertion point
                  scaleFactor   ;; X scale factor
                  scaleFactor   ;; Y scale factor
                  scaleFactor   ;; Z scale factor
                  0             ;; Rotation angle
                  :vlax-false   ;; Overlay (not bound)
                ))
    
          ;; Set the Xref layer
          (vla-put-layer xrefBlock xrefLayer)
    
          (princ "\nXref inserted and scaled successfully.")
        )
        (princ "\nInvalid Xref file selected.")
      )
    
      ;; Reset osnap mode
      (setvar "osmode" originalOsnapMode)
    
      (princ)
    )
    Thanks,

    Cadd4la

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,176
    Login to Give a bone
    0

    Default Re: Xref insert using dimscale

    Have you stepped through your code? What is the value of scaleFactor after assignment? Have you thought about using the vl-catch-all-apply function and evaluating the associated error message using the vl-catch-all-error-message function when it fails?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,745
    Login to Give a bone
    0

    Default Re: Xref insert using dimscale

    Might also be helpful if they listed which product(s) they're using, as in this instance, Civil 3D has a checkbox option under Toolspace, Settings tab, Drawing Settings dialog, Units and Zone tab, to 'Scale objects inserted from other drawings' which would make this LISP unnecessary.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 5860, Xeon W7-2495X, 128GB RAM, Dual PCIe 4.0 M.2 SSD (RAID 0), 20GB NVIDIA RTX 4000 ADA

  4. #4
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    406
    Login to Give a bone
    0

    Default Re: Xref insert using dimscale

    Quote Originally Posted by BlackBox View Post
    Might also be helpful if they listed which product(s) they're using, as in this instance, Civil 3D has a checkbox option under Toolspace, Settings tab, Drawing Settings dialog, Units and Zone tab, to 'Scale objects inserted from other drawings' which would make this LISP unnecessary.
    Blackbox,

    AutoCAD 2025

    Cadd4la

  5. #5
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    406
    Login to Give a bone
    0

    Default Re: Xref insert using dimscale

    Quote Originally Posted by Opie View Post
    Have you stepped through your code? What is the value of scaleFactor after assignment? Have you thought about using the vl-catch-all-apply function and evaluating the associated error message using the vl-catch-all-error-message function when it fails?
    Opie,

    No, I have not stepped through the code. The issue I'm having is if the file that I'm going to xref has the dimscale set to 2' and then xref it into a file it's scaled to 2' (24.00), I need it to be scaled to 0.041667.

    Thanks,

    Cadd4la

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,176
    Login to Give a bone
    0

    Default Re: Xref insert using dimscale

    Then you will need to adjust the scaleFactor variable as it correlates with the current drawing. Taking the value from the XREF drawing is fine, but you are not converting it to a different value that is relevant to the current drawing.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    Member
    Join Date
    2015-12
    Location
    Israel
    Posts
    3
    Login to Give a bone
    0

    Default Re: Xref insert using dimscale

    As long as Autodesk does not require that the units of measurement be defined in each block in the DWG file, the problem will not be solved! (Including ModelSpace and PaperSpace)

Similar Threads

  1. Replies: 0
    Last Post: 2011-11-17, 04:25 PM
  2. 2008 SCALE 1:100 xref xref xref xref- scale list issues
    By Apsis0215 in forum AutoCAD Customization
    Replies: 2
    Last Post: 2008-11-21, 08:17 PM
  3. Reading and using Dimscale to help insert Blocks in AutoCAD LT
    By landis.mark in forum AutoCAD Customization
    Replies: 3
    Last Post: 2007-03-20, 03:51 PM
  4. Tool Palette Symbols - Insert Dimscale problem
    By Doodlemusmaximus in forum AutoCAD Customization
    Replies: 15
    Last Post: 2005-12-05, 12:16 AM
  5. xref auto scale by using dimscale
    By cadd4la in forum VBA/COM Interop
    Replies: 20
    Last Post: 2005-06-14, 04:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •